简体   繁体   中英

How to use Selenium webdriver to execute test cases in Testlink

Could someone please explain how to link the webdriver scripts [tests written in eclipse] to test link tests and update results accordingly?

for Example my tests will look like this in my webdriver test plan [One class having all my tests]

@Test
testA
{
}

@Test
testB
{
}
@Test
testC
{
}

I have corresponding test cases defined in my test link database for testA, testB, testC.

When I run the script , the tests in test link DB need to be updated accordingly based on PASS/FAIL criteria.

The env am using from my tests is

eclipse [for developing     webdriver     scripts]
selenium 2.0
testlink
Testng
1234

if you are using java for developing your webdriver scripts you can use teslink java api and update the test case status using testng listeners..basically you need to have Testng listener which wil speak with testlink api to update the status of the testcase. if you dont know about testng listener here is the java api link of TestListenerAdapter

Follow the below mentioned process to update the Test results in Test link:

  • Download the Test Link jar from the link
  • In Test Link get the DEV_KEY from My Settings > Personal API access key
  • Create a instance of TestLinkAPIClient using DEV_KEY and the SERVER_URL
  • And report the Test Case results using Project Name, Test Plan Name, Test Case, Build and Results.

Refer to the sample code for more info:

     // Substitute your Dev Key Here
    public final String DEV_KEY = "2b907a29e8895c78d999dce4d2ggg0cd";

    // Substitute your Server URL Here
    public final String SERVER_URL = "http://localhost/testlink/lib/api/xmlrpc/v1/xmlrpc.php";

   // Substitute your project name Here
    public final String PROJECT_NAME = "ProjectName";

    // Substitute your test plan Here
    public final String PLAN_NAME = "Regression";

    // Substitute your build name
    public final String BUILD_NAME = "Build_Auto";


public void updateTestLinkResult(String testCase, String exception, String result) throws TestLinkAPIException {
         TestLinkAPIClient testlinkAPIClient = new TestLinkAPIClient(DEV_KEY,
                                SERVER_URL);
         testlinkAPIClient.reportTestCaseResult(PROJECT_NAME, PLAN_NAME,
                                testCase, BUILD_NAME, exception, result);
    }


String exception = null;
         try {
              driver.navigate().to("http://www.wikipedia.org/wiki/Main_Page");
              result = TestLinkAPIResults.TEST_PASSED;
              updateTestLinkResult("AT-1", null, result);
         } catch (Exception ex) {
              result = TestLinkAPIResults.TEST_FAILED;
              exception = ex.getMessage();
              updateTestLinkResult("AT-1", exception, result);
         }
        @Prasad I am using assertion before creating result like this:

      try {

          driver.navigate().to("http://www.wikipedia.org/wiki/Main_Page");
           Assert.assertEquals(ActualTitle, ExpextedTitle);
          result = TestLinkAPIResults.TEST_PASSED;
          updateTestLinkResult("AT-1", null, result);

          } 
           catch (Exception ex)
        {
          result = TestLinkAPIResults.TEST_FAILED;
          exception = ex.getMessage();
          updateTestLinkResult("AT-1", exception, result);
             }


      But I don't know why result are not showing in testlink. Can you 
      please tell me better approach to use Assertion here. 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM