Changing TestLink Test Case Execution Status Remotely Using Selenium WebDriver Via TestLink API
In the first two TestLink tutorials (part 1 and part 2), we learned how to install TestLink, set up a test project, plan tests, create test cases, manage requirements, manually execute test cases, and generate test reports.
Recommended IPTV Service Providers
- IPTVGREAT – Rating 4.8/5 ( 600+ Reviews )
- IPTVRESALE – Rating 5/5 ( 200+ Reviews )
- IPTVGANG – Rating 4.7/5 ( 1200+ Reviews )
- IPTVUNLOCK – Rating 5/5 ( 65 Reviews )
- IPTVFOLLOW -Rating 5/5 ( 48 Reviews )
- IPTVTOPS – Rating 5/5 ( 43 Reviews )
Now, we’ll focus on an advanced and significant feature of TestLink – the ability to alter the test case execution status using Selenium WebDriver code and the TestLink API. We will also show the particular Selenium code which can be applied for this API call.
This feature eliminates the need to manually log into TestLink every time to update the test case execution status. It can be done automatically through the TestLink API. This will significantly reduce the time you spend on this task.
To illustrate this feature, we’ll use Selenium WebDriver to modify the test case status and include a test note in TestLink.
Now, let’s explore how to update the TestLink test case execution status remotely using Selenium WebDriver code and TestLink API via an XML-RPC call.
Pre-Requisites
- Complete all the instructions given in the first TestLink tutorial.
- Apply Selenium for your project’s test automation.
- Automated test cases created using Selenium can be modified in TestLink using Selenium code.
Java
- Java can be obtained from this link.
- Double-click the .exe file to install Java on your device.
Eclipse
- Secure Eclipse for Windows from here.
- The download will arrive in a zip package, extract it, and save it to your computer.
Selenium Library Jars
Acquire the selenium-java jar and selenium-standalone jar from here.
Junit-4.11
Acquire the Junit 4.11 jar from this link.
TestLink Client API jars
Obtain the Test Client API jars from here.
What You Will Learn:
Enabling TestLink API
To perform automated test case execution, TestLink API configuration must be enabled in the configuration document.
To enable API, follow these steps:
Step #1) (Stop Apache service)
TestLink has been deployed in Apache already. Before making any changes to the configuration document, Apache service must be halted.
To stop the service, open Control Panel -> System and Security -> Administrative Tools.
Double-click on the “services” icon.
Click on the Apache 2.4 service and click the “stop the service” link on the left-hand side.
This will halt the Apache service.
Step #2) (Enable API in TestLink Configuration file)
Open the TestLink directory inside the htdocs folder and open the Config.inc.php file in edit mode.
Alter 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)
Begin the Apache service as described in Step 1.
Generating API Key
Each user is given an API key by TestLink, which is needed to automatically update the test case execution status.
Follow these simple steps to create the API key:
Step #1)
Launch the TestLink URL in your browser and sign in with your access credentials.
Step #2)
Open the “My Settings” link on the TestLink desktop page.
Step #3)
Press the “Generate a New Key” button in the API Interface section.
A new key should be created and displayed on the page.
Changing Execution Mode
To modify a test case execution status via API, the execution nature of the test case must be set to “Automated”.
To set the test case execution type to Automated:
Note: If you are practicing this remote status update method, you can set the execution type to Automated during test case creation.
Open a test case and hit the “settings” icon on the right-side panel. A list of operations will appear. Click the “Edit” button.
Switch the Execution Type to “Automated”.
Press the “Save” button.
Take note of the test case name, test project name, test plan name, and the build name, as these details will be needed in our Selenium code.
In our case,
Test Project Name: Gmail
Test Plan Name: SampleTestPlan
Test Case Name: GmailLogin1
Build Name: SampleBuild
Crafting Selenium Code
Launch Eclipse and create a Java project as shown below:
Right-click on the Project, select Build Path -> Configure build path, switch to the “Libraries” tab, and press the “Add External Jars” button.
Include 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
Hit the “OK” button. All jars will be added to the project build path.
Create a package inside the src folder of the java project as shown below:
Make a class inside the package with the name “AutomatedUpdateExample”.
Paste the following code into that class:
<
pre class=”brush: java; title: ; notranslate” title=””> 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