TestLink API integration with Selenium (WebDriver) script
Summary: By the end of this article you will be able to integrate WebDriver with TestLink. This integration will update the results in TestLink.This article will cover the following:
- TestLink: Download necessary JAR files
- TestLink: How to enable Test Automation API’s
- TestLink: Generate Personal API access key
- WebDriver: Creating and implementing script
- Testlink reports before and after executing the script
TestLink:
Pre-requisites: You should have TestLink setup up and running with a PROJECT that should have a TEST PLAN, BUILD/RELEASE and some TEST CASES assigned to it.
Note: We will use Project Name, Test Plan Name, Build /Release Name and Test cases ID later while writing selenium script.
Download JAR files: Download testlink-api-client-2.0.zip from Google Code and add the following jar files in your WebDriver java project class path.
‘testlink-api-client-2.0.jar’, ‘xmlrpc-common-3.1.jar’,
’xmlrpc-client-3.1.jar’, ‘ws-commons-util-1.0.2.jar’
How to enable Test Automation (API keys):
- Log In to TestLink using admin user
- Navigate to Desktop > under ‘Test Project’ > select ‘Test Project Management’
- Open appropriate Project > click on check box “Enable Test Automation (API keys)” > click on ‘Save’ button.
Generate Personal API
access key:
- Click on link ‘My Settings’ > opens Account Settings
- API Interface section: Click on ‘Generate a new key’ button > you will get an access key.
Creating and
Implementing Script: Use the below mentioned code but make sure that you make the necessary changes to the file:
Example: Just change Test case ID's as per your test cases.
Example: Just change Test case ID's as per your test cases.
Nice post and it's helpful also......
ReplyDeleteNice stuff.. helped me a lot in my Imation project.
ReplyDeleteNicely explained step by step. Very useful for fresher like me.
ReplyDeleteThanks for post. :)
did this work for you???
DeleteAjeet,
DeleteYes, it works. Please provide your exact steps and error if it is not working for you.
Thanks.
-
Are you integrate your test with jenkins?
ReplyDeleteHi Shivraj,
ReplyDeleteGreat! But when I run the above script I get following error stacktrace. Any idea?
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.getProjects(TestLinkAPIClient.java:726)
at testlink.api.java.client.TestLinkAPIHelper.getProjectInfo(TestLinkAPIHelper.java:64)
at testlink.api.java.client.TestLinkAPIHelper.getProjectID(TestLinkAPIHelper.java:48)
at testlink.api.java.client.TestLinkAPIClient.reportTestCaseResult(TestLinkAPIClient.java:184)
at com.visualiq.testlink.Seltestlinkinte.updateTestLinkResult(Seltestlinkinte.java:80)
at com.visualiq.testlink.Seltestlinkinte.Searchitem(Seltestlinkinte.java:46)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:100)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:646)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:811)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1137)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:129)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:112)
at org.testng.TestRunner.privateRun(TestRunner.java:753)
at org.testng.TestRunner.run(TestRunner.java:607)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:368)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:363)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:321)
at org.testng.SuiteRunner.run(SuiteRunner.java:270)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1284)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1209)
at org.testng.TestNG.runSuites(TestNG.java:1124)
at org.testng.TestNG.run(TestNG.java:1096)
at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:132)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:236)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:81)
Caused by: org.apache.xmlrpc.XmlRpcException: Failed to read servers response: Connection refused: connect
at org.apache.xmlrpc.client.XmlRpcStreamTransport.sendRequest(XmlRpcStreamTransport.java:150)
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)
... 32 more
I would appreciate your help
How do I run automation script from TestLink? Above code shows updating result in TestLink when script is run using Selenium.
ReplyDeleteAmar
Hello,
ReplyDeleteCan anyone know how to call testlink URL with HTTPS ?