Tech Me More

To quench our thirst of sharing knowledge about our day to day experience & solution to techincal problems we face in our projects.

Advertise with us !
Send us an email at

Saturday, September 3, 2016

How to get Test Case Detail from testlink using TestLink Java API?

Getting test case detail from testlink using API is quite needful when displaying results in Reports.

To get test case related detail you will need testlink-java-api.


  1. TestLink-Java-API
  2. Java 1.7 or higher
  3. Maven

Since, TestLink-Java-API depends on mulitple other jars, it ia adviceable to create a Maven project and add the below dependencies in POM.XML

  <!-- Commons APIs -->
  <!-- Logging APIs -->
  <!-- Configuration APIs -->
  <!-- XML-RPC related APIs -->

Use the below code to retrieve Test case description, Steps to execute, Expected results etc. using External test case id.

public void getTestDetailFromTestLink() {
  String testCaseDescription = "", expectedResults = "", steps = "";
  URL url;
  try {
   url = new URL("http://localhost/testlink/lib/api/xmlrpc/v1/xmlrpc.php");

   String devKey = "5062c3fertf9b8886e0edd0ffdf6b14";
   TestLinkAPI api = new TestLinkAPI(url, devKey);
   TestCase tCase = api.getTestCaseByExternalId("P1-46039", 1);

   testCaseDescription = tCase.getSummary();

   List<TestCaseStep> list = tCase.getSteps();
   Iterator<TestCaseStep> itr = list.iterator();
   while (itr.hasNext()) {
    TestCaseStep tcs =;
    expectedResults = tcs.getExpectedResults();
    steps = tcs.getActions();

  } catch (Exception e) {

  System.out.println("Description :"+testCaseDescription);
  System.out.println("Expected Result :"expectedResults);
  System.out.println("Steps to Execute :"+steps);

Above code produces the below output.

Description :Verify that on selecting Die Hard Techy from Side menu takes user to blog screen.

Expected Result :User should be navigated to Screen.

Steps to Execute :1.Open DieHardTechy website. 2.Select Die Hard Techy.

Monday, August 29, 2016

How to drag and drop an element to location specified by X, Y coordinate using selenium

Drag and drop is now common functionality across many web applications for interactive user interface and easy upload. 

To automate drag and drop in your automation test script, selenium provides a class called Actions for interactive actions.

1. Launch
2. Drag and release the element an X=250 and Y= 10 Pixels.

To automate the above scenario using Selenium Webdriver , we would need to use dragAndHold(WebElement element) function of selenium library.


package seleniumInteractive;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.interactions.Actions;

public class DragAndDrop {

	static {
		System.setProperty("", "Chrome driver location");

	public static void main(String[] args) {

		WebDriver driver = new ChromeDriver();
		WebElement element = driver.findElement("draggable"));
		Actions action = new Actions(driver);
		action.clickAndHold(element).moveByOffset(250, 10).build().perform();


POC videos:

Please follow our other blog Tester in you for more updates and tutorials of Selenium.

Tuesday, August 9, 2016

Java client to send a file or inputstream to Jersey Restful API

We  often run in the need of Java client where we can send a file to Restful web services. To do so we will need a multi part request and send it to api. Below code demonstrate how to do it using java.

package com.test;

import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.mime.MultipartEntityBuilder;
import org.apache.http.impl.client.HttpClientBuilder;

public class JavaClient {

 public int callAPI() throws Exception {
  String url = "http://localhost:8080/testAPI/rest/fileupload";
  HttpClient httpclient = HttpClientBuilder.create()
  HttpPost httppost = new HttpPost(url);
  MultipartEntityBuilder reqEntity = MultipartEntityBuilder.create();
  reqEntity.addBinaryBody("file", new File(""));
  HttpResponse response = httpclient.execute(httppost);
  int statuscode = response.getStatusLine().getStatusCode();
  return statuscode;


You can also use InputStream instead of File if you don't want to send File.

To send the inputstream instead of file please replace the statement  reqEntity.addBinaryBody("file", new File(filePath));

with reqEntity.addBinaryBody("file", fileIPStream); in above code snippet. 

Monday, February 8, 2016

How to run two different application on two physical android devices in parallel?

Parallel execution of android applications have become a need now days given that number of test scenarios are higher. 

Parallel execution is done to achieve maximum test coverage with minimal time.

Appium provides a way for parallel execution.

To achieve this , we have to do the following steps.
  1. We need to start 2 appium instances on different ports.
  2. Boot strap port numbers for both the instances must be different.
  3. provide the unique identifier of physical devices using -U flag.
  4. If you are trying to run an Hybdrid application in parallel, make sure you start chrome driver on 2 different ports.

You can skip the point 4 if you are automating native android apps.

To start appium server you must have node.js installed or you can use default node executable residing inside appium installation directory.

1. Open a command prompt in admin mode and navigate till main.js file inside appium installation directory.

Main.js is find here: 

C:\Program Files (x86)\Appium\node_modules\appium\lib\server

2. run the below commands in different command prompt window. 

node main -p 4725 -bp 2293 -U place device 1 UDID--chromedriver-port 6000

node main -p 4724 -bp 2292 -U place device 2 UDID--chromedriver-port 6001

You will see appium server up and running on 2 different ports.

Instance 1

Instance 2

3. Now go to your testng.xml file and pass port number and device name as parameter from your testng.xml suite file.

Please make sure parallel attribute inside <suite> must be set to tests.

<!DOCTYPE suite SYSTEM "">
<suite name="Preserve order test runs" parallel="tests">
   <test name="Test for account settings Mobile" preserve-order="true" >
        <parameter name="appName" value="accounts_582.apk" />
        <parameter name="deviceName" value="HTC Nexus 9" />   
        <parameter name="paramName" value="4724" />     
          <class name="omniauto.tests.Accounts_AndroidTest"></class> 
              <class name="omniauto.tests.AggregatedAccount_Settings"></class> 
              <class name="omniauto.tests.ManualAccountSettings_Test"></class> 
    <test name="Test suite for account group setting Mobile" preserve-order="true" >
        <parameter name="appName" value="accountgroupsettings_582.apk" />
        <parameter name="deviceName" value="Samsung I9500 Galaxy S4" />
        <parameter name="paramName" value="4725" />
            <class name="omniauto.tests.Account_Group_Settings"></class>

4. Use that port number in forming your driver instance. 

driver = new AppiumDriver(new URL(""+portNum+"/wd/hub"), capabilities);

Happy learning ! :)