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

By Vijay

By Vijay

I'm Vijay, and I've been working on this blog for the past 20+ years! I’ve been in the IT industry for more than 20 years now. I completed my graduation in B.E. Computer Science from a reputed Pune university and then started my career in…

Learn about our editorial policies.
Updated January 17, 2025

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

In the 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.

Updating TestLink Test Case Execution Status

_Update TestLink Test Case Execution

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

To demonstrate this feature, we are using Selenium WebDriver and updating the test case status along with test notes 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.

Pre-Requisites:

  • All the steps explained in TestLink tutorial #1 should be done.
  • You are using Selenium for test automation on your project.
  • Selenium code can update test cases automated using Selenium in TestLink.

Java

  • You can download Java from here.
  • Double-click on the .exe file and install Java on your system.

Eclipse

  • Download Eclipse for Windows from here.
  • It will be downloaded as a zip package. Extract it and place it on your local drive.

Selenium Library Jars
Download the selenium-java jar and selenium-standalone jar from here.

Junit-4.11
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 the configuration file, Apache should be stopped.

To do that, open Control Panel -> System and Security -> Administrative Tools.
Double-click on the “services” icon.

services

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 the TestLink folder inside htdocs folder and open Config.inc.php 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 the 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 the Test case execution status in an automated way.

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

Step #1: Open TestLink URL in your browser and log in with your user credentials.

Step #2: Open the “My Settings” link on the TestLink desktop page.

My Settings

Step #3: Click on the “Generate a New Key” button in the API Interface section.

Generate a New Key

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

new key generated

Changing Execution Mode

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

Changing the 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 themselves.

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

settings

Change the Execution Type to “Automated”.

Automated

Click on the “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 the below figure.

Writing Selenium Code

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

Add the following jars to the build path:

  • Junit 4.11 jar
  • Selenium-standalone server jar
  • Selenium – java jar & all libs (Library folder) jar
  • TestLink Client API jar & all lib (Library folder) jar
build path

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

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

Create a package

Create a class inside the package with the 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;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
 
import testlink.api.java.client.TestLinkAPIClient;
import testlink.api.java.client.TestLinkAPIException;
import testlink.api.java.client.TestLinkAPIResults;
 
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);
}
 
@Test
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;
try{
driver.manage().window().maximize();
driver.get("https://accounts.google.com/ServiceLogin?service=mail&passive=true&rm=false&continue=https://mail.google.com/mail/&ss=1&scc=1<mpl=default<mplcache=2&emr=1");
driver.findElement(By.id("Email")).sendKeys("testlink.msoftgp");
driver.findElement(By.id("Passwd")).sendKeys("*******");
driver.findElement(By.id("signIn")).click();
driver.switchTo().defaultContent();
wait.until(ExpectedConditions.visibilityOfElementLocated(By.linkText("+Testlink")));
result= TestLinkAPIResults.TEST_PASSED;
notes="Executed successfully";
}
catch(Exception e){
result=TestLinkAPIResults.TEST_FAILED;
notes="Execution failed";
}
finally{
 
a.reportResult(testProject, testPlan, testCase, build, notes, result);
driver.quit();
}
}
}

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

Save the file.

Executing Selenium Code

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

If the code is executed successfully without any exceptions, then the 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 by executing the test.

execute code

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

Before Execution

Before Execution

After Execution

After Execution

Conclusion

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

The testers can easily update test case execution status directly in TestLink without having to log in. 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 and automation experts.

With this, we are concluding our TestLink tutorial series. Post your queries in the comments.

Was this helpful?

Thanks for your feedback!

Recommended Reading


54 thoughts on “How to Update TestLink Test Case Execution Status Remotely Through Selenium – Tutorial #3”

  1. @Tanaya – Ensure , whether you’ve enabled API in Testlink Config file and check whether your Developer key is correct.

    If, Still you’re facing the same problem then, generate a new developer key and use it in your code.

    Reply
  2. I am getting the below error:

    The xml-rpc call to TestLink API method tl.reportTCResult failed.
    Result[0] = {code=200, message=(reportTCResult) – Parameter platformname OR platformid is required, but has not been provided}

    where do I pass the platformname? Any idea ? Thanks

    Reply
  3. Thanks a lot very helpful tutorial.it is working fine but i am not able update status on TEST LINK. I am getting bellow ERROR:

    “”Exception in thread “main” testlink.api.java.client.TestLinkAPIException: The test case identifier null was not found and the test case CPIDM-8937: 20150604-03:58:17 SSO_Email_Forgot_Password could not be accessed to report a test result to test plan Sample – Smoke Suite.””

    Reply
  4. Please share the code. Also even though I have added the dependency in pom.xml .

    br.eti.kinoshita
    testlink-java-api
    1.9.8-1

    Build is throwing error, package testlink.api.java.client does not exist. How to resolve this? Are you guys also facing the same error?

    Reply
  5. Good article.
    Is it possible to Update TestLink Test Case Execution Status Remotely while executing Web Services automation?

    Thanks.

    Reply
  6. I’m getting below testlink exception after running the junit test-

    testlink.api.java.client.TestLinkAPIException:
    The xml-rpc call to TestLink API method tl.getProjects failed.
    Result[0] = {message=Can not authenticate client: invalid developer key, code=2000}

    Please please help

    Reply
  7. Dear All,

    Please follow the below mentioned instruction to get rid of “The call to the xml-rpc client failed” exception
    1. Download testlink.eclipse.plugin_0.97.11.zip and add all library files to you lib folder of project
    2. Make sure you are using jdk1.8.0_261
    3. After adding library files reload the project
    4. Try to update it will work

    Thanks
    Sampathkumar

    Reply
  8. great article,
    worked a treat! We now have integration for out selenium test cases, which is a big improvement.
    Does anyone konw if there is anything comparable with with QTP / UFT?
    thanks

    Reply
  9. Hi ,

    Thanks For the post , it is very useful for me to execute the testcases from test-Link using Jenkins. Can you please help me out for , how to extract the the Testcases within the build.

    i.e. Execute the all the testcases with in the build.

    Thanks

    Reply
  10. Hi Team,

    Appreciate your effort to explain the procedure. However I am looking for Test step level result logging. Your help will be appreciable. Thanks in Advance.

    Regards,
    Vishal D

    Reply
  11. Hi great tutorial but I’m having an issue which is the same with the other guys here. ” The call to the xml-rpc client failed” I’ve already updated config.inc in testlink root directory. I’ve also enable test automation API Key on my testlink test project. I’m using testlink-api-client 2.0. Thanks!

    Reply
  12. Hi,
    I want to install XAMPP for testlink. I am using windows 8 64 bit. Because of this i am unable to install. Please help me..

    Thanks

    Reply
  13. Thanks for the post, it helped me to update status through selenium. Only issue I see is it takes a lot of time to update the status in Testlink. I have nearly 300 cases and it takes almost 3 to 4 hours to update the status.
    Is there a quick soltuion to this, please let me know.

    Reply
  14. I need to integrate selenium with testlink for automated testing.
    i am using below code

    TestLinkAPIClient api = new TestLinkAPIClient(DEVKEY, URL);
    api.reportTestCaseResult(TestProject, TestPlan, Testcase, Build, Notes,Result);

    But getting exception

    “testlink.api.java.client.TestLinkAPIException:
    The xml-rpc call to TestLink API method tl.reportTCResult failed.
    Result[0] = {message=(reportTCResult) – Parameter platformname OR platformid is required, but has not been provided, code=200}”

    Reply
  15. Hi,

    Thank you for the useful information.
    We are using same in our project to update 300+ test cases through XML-RPC call and it is taking 4+ hours to update same.
    As we have totally around 2000 test cases to be updated. Can you please suggest the ways to increase its performance.

    Advance thank you!

    Reply
  16. Hi,
    Good article.
    Is it possible to Update TEST LINK Test Case Execution Status Remotely while executing Appium script??

    Reply
  17. I would like to know how to automatically update the number of test cases executed by each person in the project. How many test cases have not run, how many blocked. how many test cases are assigned to each individual.

    Reply
  18. Really nice tutorial but I want to attach the log file to failed test cases so Is it possible using API if yes please provide its steps and API

    Reply
  19. Hello all, Thank’s fos sharing thos pst is very useful, now i’m not able to update status in Testlink after run them with Nunit Conole (my tests are developped in visula studion (Selenium c#)
    I’m bloked and i need your help please 🙂

    Reply
  20. I was able to automatically update the status of one test case in TestLink after the automation test was run in Selenium. But how to update the results for several test cases in a build. Please help me.

    Reply
  21. Will you please explain the meaning of below mention line:

    wait.until(ExpectedConditions.visibilityOfElementLocated(By.linkText(“+Testlink”)));

    Reply
  22. I am trying to integrate testlink with selenium webdriver, using the following code

    import org.testng.annotations.AfterSuite;
    import org.testng.annotations.BeforeSuite;
    import org.testng.annotations.Test;
    import org.openqa.selenium.By;
    import org.openqa.selenium.WebDriver;
    import org.openqa.selenium.chrome.ChromeDriver;
    import org.openqa.selenium.firefox.FirefoxDriver;
    import org.openqa.selenium.support.ui.ExpectedConditions;
    import org.openqa.selenium.support.ui.WebDriverWait;
    import testlink.api.java.client.TestLinkAPIClient;
    import testlink.api.java.client.TestLinkAPIException;
    import testlink.api.java.client.TestLinkAPIResults;

    public class TestLink
    {
    public static WebDriver driver;
    //Enter your project API key here.
    public static String DEVKEY=”cb5f984421c93f1efb42b53a43f83c3a8d04d2b1fa2f17cb798054a944297d91″;
    //Enter your Test Link URL here
    public static String URL= “http://192.168.129.33/testlink/index.php”;

    //Enter your Test Project Name here
    String testProject=”Test Project2″;

    //Enter your Test Plan here
    String testPlan=”TesT Plan2″;

    //Enter your Test build here
    String build=”Test Plan 1″;

    @BeforeSuite

    public void setUp() throws Exception
    {
    //Enter the path for your browser exe file here
    System.setProperty(“webdriver.chrome.driver”,”D:\\Selenium\\chromedriver.exe”);
    driver = new ChromeDriver();
    }

    @Test

    public void Test()throws Exception

    {
    String result = “”;
    String exception = “”;

    try
    {
    driver.manage().window().maximize();
    //Enter your applicaton URL.
    driver.navigate().to(“https://www.gmail.com”);

    //enter ur username
    driver.findElement(By.xpath(“.//* [@id=’Email’]”)).sendKeys(“rinkle95@gmail.com”);

    //click on next
    driver.findElement(By.xpath(“.//*[@id=’next’]”)).click();

    //Enter your password
    // driver.findElement(By.xpath(“.//*[@id=’Passwd’]”)).click();
    // driver.findElement(By.xpath(“.//*[@id=’Passwd’]”)).sendKeys(“1233”);
    driver.findElement(By.id(“Passwd”)).sendKeys(“12345”);
    //Find Xpath of your click button and enter here
    driver.findElement(By.xpath(“.//*[@id=’signIn’]”)).click();
    driver.switchTo().defaultContent();

    result= TestLinkAPIResults.TEST_PASSED;
    //Enter your test case ID here
    updateTestLinkResult(“TC–1”, null, result);

    }

    catch(Exception e)
    {
    result = TestLinkAPIResults.TEST_FAILED;
    exception = e.getMessage();
    updateTestLinkResult(“TTC–1”, exception, result);
    }
    }

    public void updateTestLinkResult(String testCase, String exception, String result) throws TestLinkAPIException
    {
    TestLinkAPIClient testlinkAPIClient = new TestLinkAPIClient(DEVKEY,URL);
    testlinkAPIClient.reportTestCaseResult(testProject, testPlan, testCase, build, exception, result);

    }

    @AfterSuite

    public void close()
    {
    driver.quit();
    }
    }

    after that, this code is running properly but not updating anything in testlink. Could anyone please help me resolving this issue.I just want to mark testcase execution in testlink through selenium webdriver.

    Reply
  23. I’m getting below testlink exception after running the junit test-

    testlink.api.java.client.TestLinkAPIException:
    The xml-rpc call to TestLink API method tl.getProjects failed.
    Result[0] = {message=Can not authenticate client: invalid developer key, code=2000}

    at testlink.api.java.client.TestLinkAPIClient.
    execXmlRpcMethodWithCache(TestLinkAPIClient.java:1209)

    at testlink.api.java.client.TestLinkAPIClient.
    getProjects(TestLinkAPIClient.java:726)

    at testlink.api.java.client.TestLinkAPIHelper.
    getProjectInfo(TestLinkAPIHelper.java:64)

    at testlink.api.java.client.TestLinkAPIHelper.
    getProjectID(TestLinkAPIHelper.java:48)

    ….

    Reply
  24. Hi, and thank you for great tutorials and articles!

    I’m new to software testing and automation, so I’m sorry in advance if this comes through as noob questions.

    I would like to accomplish updating test case execution status directly in TestLink with the help of Selenium.
    Is there any way to this working with c# and Visual Studio? If so, where can I learn to set it up?

    Best regards.

    Reply
  25. Hi,

    I followed your example but unfortunately I got stuck in this error:

    testlink.api.java.client.TestLinkAPIException: The call to the xml-rpc client failed.
    at testlink.api.java.client.TestLinkAPIClient.executeXmlRpcMethod(TestLinkAPIClient.java:1266)
    at testlink.api.java.client.TestLinkAPIClient.execXmlRpcMethodWithCache(TestLinkAPIClient.java:1195)
    at testlink.api.java.client.TestLinkAPIClient.about(TestLinkAPIClient.java:145)
    at testing.utils.TestLinkUtils.reportResult(TestLinkUtils.java:38)
    at testing.login_page.GeneralAdminLogIn.I_should_see_the_title(GeneralAdminLogIn.java:99)
    at ?.Then I should see the title “Administration des produits Airs Serveur”/IdeaProjects/GeneralAdminTest/src/test/resources/features/login_page/GeneralAdminLogIn.feature:14)
    Caused by: org.apache.xmlrpc.client.XmlRpcClientException: Failed to parse servers response: Expected methodResponse element, got br
    at org.apache.xmlrpc.client.XmlRpcStreamTransport.readResponse(XmlRpcStreamTransport.java:177)
    at org.apache.xmlrpc.client.XmlRpcStreamTransport.sendRequest(XmlRpcStreamTransport.java:145)
    at org.apache.xmlrpc.client.XmlRpcHttpTransport.sendRequest(XmlRpcHttpTransport.java:94)
    at org.apache.xmlrpc.client.XmlRpcSunHttpTransport.sendRequest(XmlRpcSunHttpTransport.java:44)
    at org.apache.xmlrpc.client.XmlRpcClientWorker.execute(XmlRpcClientWorker.java:53)
    at org.apache.xmlrpc.client.XmlRpcClient.execute(XmlRpcClient.java:166)
    at org.apache.xmlrpc.client.XmlRpcClient.execute(XmlRpcClient.java:157)
    at org.apache.xmlrpc.client.XmlRpcClient.execute(XmlRpcClient.java:146)
    at testlink.api.java.client.TestLinkAPIClient.executeXmlRpcMethod(TestLinkAPIClient.java:1232)
    at testlink.api.java.client.TestLinkAPIClient.execXmlRpcMethodWithCache(TestLinkAPIClient.java:1195)
    at testlink.api.java.client.TestLinkAPIClient.about(TestLinkAPIClient.java:145)
    at testing.utils.TestLinkUtils.reportResult(TestLinkUtils.java:38)
    at testing.login_page.GeneralAdminLogIn.I_should_see_the_title(GeneralAdminLogIn.java:99)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at cucumber.runtime.Utils$1.call(Utils.java:34)
    at cucumber.runtime.Timeout.timeout(Timeout.java:13)
    at cucumber.runtime.Utils.invoke(Utils.java:30)
    at cucumber.runtime.java.JavaStepDefinition.execute(JavaStepDefinition.java:35)
    at cucumber.runtime.StepDefinitionMatch.runStep(StepDefinitionMatch.java:37)
    at cucumber.runtime.Runtime.runStep(Runtime.java:298)
    at cucumber.runtime.model.StepContainer.runStep(StepContainer.java:44)
    at cucumber.runtime.model.StepContainer.runSteps(StepContainer.java:39)
    at cucumber.runtime.model.CucumberScenario.run(CucumberScenario.java:48)
    at cucumber.runtime.model.CucumberFeature.run(CucumberFeature.java:163)
    at cucumber.runtime.Runtime.run(Runtime.java:120)
    at cucumber.api.cli.Main.run(Main.java:36)
    at cucumber.api.cli.Main.main(Main.java:18)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:140)
    Caused by: org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 7; Expected methodResponse element, got br
    at org.apache.xmlrpc.parser.XmlRpcResponseParser.startElement(XmlRpcResponseParser.java:98)
    at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown Source)
    at org.apache.xerces.parsers.AbstractXMLDocumentParser.emptyElement(Unknown Source)
    at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)
    at org.apache.xerces.impl.XMLNSDocumentScannerImpl$NSContentDispatcher.scanRootElementHook(Unknown Source)
    at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
    at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
    at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
    at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
    at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
    at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
    at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
    at org.apache.xmlrpc.client.XmlRpcStreamTransport.readResponse(XmlRpcStreamTransport.java:175)
    … 34 more

    My Testlink is installed on a server. Could you please help me out with this problem?
    Thanks,
    Olimpia

    Reply
  26. Thanks for the post, i face an performance issue . when i run the script with multiple test case it take 1 min to update the status in testlink. i have 1000 testcases in repository (test Spec).

    Reply
  27. I also getting the below error:

    The xml-rpc call to TestLink API method tl.reportTCResult failed.
    Result[0] = {code=200, message=(reportTCResult) – Parameter platformname OR platformid is required, but has not been provided}

    Can you help or give a pointer to resolving the issue. Thanks

    Reply
  28. Hi ! can you help me ! How To Update TestLink Test Case Execution Status Remotely using cypress instead of selenium?

    Reply
  29. Hi Vijay/Srinivasan,

    I was able to automatically update the status of one test case in TestLink after the automation test was run in Selenium. But how to update the results for several test cases in a build. Please help me.

    Reply
  30. I’m getting below testlink exception after running the junit test-

    testlink.api.java.client.TestLinkAPIException:

    Reply
  31. Hi!
    I’m trying to get a result by step, actually, I have the script to execute and pass or fail the complete test case, can you please help me? Thanks!

    Reply
  32. Hi,
    I am getting an error.Please share your views

    testlink.api.java.client.TestLinkAPIException: The test case identifier null was not found and the test case 485 could not be accessed to report a test result to test plan UIAutomatoion.

    Reply

Leave a Comment