How to Update TestLink Test Case Execution Status Remotely Through Selenium – Tutorial #3

Updating TestLink Test Case Execution Status Remotely Through Selenium WebDriver Using TestLink API

In first two TestLink tutorials (part 1 and part 2) we learned TestLink installation, creating a test project, test plan, test cases, requirements management, manual execution of test cases, and generating test reports.

Today, we will learn one advanced and important feature of TestLink i.e. updating test case execution status through Selenium WebDriver code using TestLink API. We will also provide the exact Selenium code that you can use for this API call.

With this feature, you don’t have to login into TestLink each time to update the test case execution status. You can do it automatically using TestLink API. This will save your lot of manual execution time.

To demonstrate this feature we are using Selenium WebDriver and updating the test case status along with test note in TestLink.

Let’s have a deep look at – how to update test case execution status remotely through Selenium WebDriver code and TestLink API through XML-RPC call.

What You Will Learn:

What will you learn in this tutorial?


  1. All the steps explained in TestLink tutorial #1 should be done.
  2. You are using Selenium for test automation on your project.
  3. Test cases which are automated using Selenium can be updated in TestLink through Selenium code.


– You can download java from here.

– Double click on the exe file and install java on your system.


– Download Eclipse for windows from here.

– It will be downloaded as a zip package, extract and place it on your local drive.

Selenium Library Jars

Download selenium-java jar and selenium-standalone jar from here.


Download Junit 4.11 jar from here.

TestLink Client API jars

Download Test Client API jars from here.

Enabling TestLink API

For automated test case execution, TestLink API configuration should be enabled in the configuration file.

To Enable API to follow these steps:

Step -1 (Stop Apache service)

TestLink has already deployed in Apache. Before doing any modifications in configuration file Apache should be stopped.

To do that, open Control Panel -> System and Security -> Administrative Tools.

Double click on “services” icon.

Click on Apache 2.4 service and click on the “stop the service” link appearing on the left side.

It will stop the Apache service.

Step -2 (Enable API in TestLink Configuration file)

Open TestLink folder inside htdocs folder and open file in edit mode.

Change the following line to “TRUE”.

 /* [API] */
/** XML-RPC API availability - do less than promised 
FALSE => user are not able to generate and set 
his/her API key. XML-RPC server do not check this 
config in order to answer or not a call.

$tlCfg->api->enabled = TRUE; 

Save and close the file.

Step -3 (Start Apache service)

Open Apache service as described in Step 1 and start it.

Generating API Key

TestLink provides an API key for each user which is essential for updating Test case execution status in an automated way.

API key can be generated through simple steps as explained in below steps:

Step -1

Open TestLink URL in your browser and login with your user credentials.

Step -2

Open “My Settings” link on the TestLink desktop page.

Step -3

Click on the “Generate a new Key” button in the API Interface section.

A new key will be generated and displayed on the page.

Changing Execution Mode

To update a Test case execution status through API, its execution type should be “Automated”.

Changing test case execution type to Automated:

Note: If you are following this remote status update practice you can update the execution type to Automated while creating the test cases itself.

Open a Test case and click on “settings” icon appearing on the right side panel. It will display a list of operations. Click on “Edit” button.

Change Execution Type to “Automated”.

Click on “Save” button.

Note down the Test case name, Test project name, Test plan name, and the build name. We will need these details in our Selenium code.

In our example,

Test Project Name: Gmail

Test Plan Name: SampleTestPlan

Test Case Name: GmailLogin1

Build Name: SampleBuild

Writing Selenium code

Open Eclipse, and create a Java project as shown in below figure. (Click to enlarge image)

Right-click on the Project, go to Build Path -> Configure build path, switch to “Libraries” tab and click on “Add External Jars” button.

Add following jars in the build path

  1. Junit 4.11 jar
  2. Selenium-standalone server jar
  3. Selenium – java jar & all libs (Library folder) jar
  4. TestLink Client API jar & all lib (Library folder) jar

Click “OK” button. All jars will be added to the project build path.

Create a package inside src directory of the java project as shown below:

Create a class inside the package with name “AutomatedUpdateExample”.

Copy the following code into that class:

 package com.test;

import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;


public class AutomatedUpdateExample {

public static String DEVKEY="2f404203b306bd8dd811a7f824c194d0";
public static String URL="http://localhost/testlink/lib/api/xmlrpc/v1/xmlrpc.php";

public static void reportResult(String TestProject,String TestPlan,String Testcase,String Build,String Notes,String Result) throws TestLinkAPIException{
TestLinkAPIClient api=new TestLinkAPIClient(DEVKEY, URL);
api.reportTestCaseResult(TestProject, TestPlan, Testcase, Build, Notes, Result);

public void Test1()throws Exception
AutomatedUpdateExample a=new AutomatedUpdateExample();
WebDriver driver=new FirefoxDriver();
WebDriverWait wait=new WebDriverWait(driver, 600);
String testProject="Gmail";
String testPlan="SampleTestPlan";
String testCase="GmailLogin1";
String build="SampleBuild";
String notes=null;
String result=null;
result= TestLinkAPIResults.TEST_PASSED;
notes="Executed successfully";
catch(Exception e){
notes="Execution failed";

a.reportResult(testProject, testPlan, testCase, build, notes, result);

[Note: update Test project, Test plan, Test case and Build name in above code as per your project details]

Save the file.

Executing Selenium Code

Depending on the execution of the test in Selenium, TestLink test case status will be updated as either “Passed” or “Failed”.

If the code executed successfully without any exceptions then test case status will be updated as “Passed”. In case of any exceptions test case status will be updated as “Failed”.

To execute code, just right click on the file and select Run As -> Junit Test. It will start executing the test.

(Click to enlarge image)

Now open TestLink in your browser and see the execution status for the test case. It should be updated.

Before Execution

After Execution

(Click to enlarge image)


Hope we have clearly explained how to update TestLink test case execution status automatically using TestLink API.

The testers can easily update test case execution status directly in TestLink without having to login. This will surely help you save your precious time and money. :)

This again proves that TestLink is a good open source Test Management Tool, which can be used by manual testers as well as automation experts.

With this, we are concluding our TestLink tutorial series. Feel free to post your queries in comments.