Integrating Selenium scripts written using TestNG with Slik Central test management tool

565 views Asked by At

I've developed automation scripts using Selenium and TestNG. Can we integrate developed automation scripts with manual test cases documented in silk central. My Client wants to kick start the execution of automation scripts from Silk Central it self.

I've made some ground work and got to know that Silk central supports Junit. Please let me know how to run the scripts developed using TestNG in silk central.

1

There are 1 answers

0
Johnbo On

Selenium scripts can be invoked from Silk Central as far as they are JUnit-based or NUnit/MSTest. All you have to do is creating a source control profile, so Silk Central can see your code. Then, create a test container and append child tests of the desired type, specifying the classpath to your tests.

However, you say that you want to kick start the execution from Silk Central itself, in conjunction with manual tests. This sounds like the Keyword-Driven Testing functionality added on Silk Central 16.0.

You can create a New Child Test of the KDT type, where your client will be able to create keywords (i.e. test methods) with parameters. If those keywords already have Selenium automation code associated, you will be able to execute them directly after creating the Keyword-Driven test. If not, you can develop the method, making the Silk Central test executable.

First, you need to download the Java Keyword-Driven Library Builder from Silk Central’s Help --> Tools tab and add the com.borland.silk.keyworddriven.jar to your Selenium project classpath. Then, create your methods with the same name given in Silk Central, and tag them with com.borland.silk.keyworddriven.annotations.Keyword annotation.

For instance, if your client created the keyword openBrowser with the parameter "http://stackoverflow.com", your code should look like this:

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import com.borland.silk.keyworddriven.annotations.*;

public class MyKeywordLibrary{
  private WebDriver driver;  

  @Keyword
  public void openBrowser(String url) {
    driver = new FirefoxDriver();
    driver.get(url);
  }
}

As you can see, the parameter had no name in Silk Central, so you can give it the one that you prefer in your code (url in the sample).

Once your code is finished, you have to upload your keyword library to Silk Central. In order to do that, compile your sources to a jar archive and call the DocBuilder class from the jar you previously downloaded, as follows:

java -cp ./com.borland.silk.keyworddriven.jar com.borland.silk.keyworddriven.library.docbuilder.DocBuilder MyKeywordLibrary Java ./output ./MyKeywordLibrary.zip

Where MyKeywordLibrary is the name of your compiled keyword library. Finally, upload the library to Silk Central by selecting Tests --> Libraries --> Properties tab --> Upload.

You can find more information at Silk Central's blog: Keyword-driven testing with Selenium.