IMPORTANT NOTICE:  As of 21 February, anything posted in this community WILL NOT BE MIGRATED to our new community site.   We have pulled all user information and data from this site and are now in an approximately week long process of importing users, roles, and data to our new site.  We are leaving this site open and active so you can post and hopefully get a response until the migration is complete.   Once complete, the URL  that currently takes you to this site will take you to our new site so your bookmarks will work as always.  Please read the information on a New Login Process

Advanced logging for your Selenium tests with Silk4J

In the previous posts about Python and Ruby, we have introduced the idea of generating TrueLog files when running Selenium tests through the Silk Test Open Agent. In this post we want generate similar TrueLog files for Java-based and JUnit-based tests. There is an important difference to the previous test types: When using Java and JUnit, you can leverage the full Silk4J tooling and infrastructure, which makes generating TrueLog files for your Selenium scripts very easy.


The architecture differs to the ones used for Ruby and Python and looks like the following:

The important difference to the other languages is here that you can use the JTF library of Silk Test to start the browser, and you can then interact with the browser through WebDriver.
Note: You can use the JTF library to do a lot more, for example interacting with the native parts of the browser.

Getting started

Start by creating a new Silk4J project for your web application in Eclipse. Select your preferred browser and decline recording for the time being. Instead of recording new actions, import or copy and paste your existing JUnit-based Selenium tests into the new Silk4J project.

If you get compile errors because of the missing WebDriver classes, don't worry. Just use the Add WebDriver Capability option in the Silk4J section of the context menu of the project:

This adds a reference to the WebDriver client library which is shipped with Silk Test, and which is by default installed to C:\Program Files (x86)\Silk\SilkTest\ng\SeleniumJavaClientBindings. If you don't want to use these client bindings, feel free to use Maven, Gradle, or any other dependency management tool.

Code changes

The only major change you have to apply to your existing tests is the way the browser is started. For example, if your tests look like the following:

public class InsuranceWebTests {
  private static WebDriver driver;

  public static void beforeClass() {
    driver = new ChromeDriver();
  public static void afterClass() {
  public void setup() {
    new WebDriverWait(driver, 10).until(ExpectedConditions.elementToBeClickable(By.linkText("Demo Application"))).click();
  public void teardown() {
  public void testLogin() {
    new WebDriverWait(driver, 10).until(ExpectedConditions.elementToBeClickable("login-form:email"))).sendKeys("");
    new WebDriverWait(driver, 10).until(ExpectedConditions.elementToBeClickable("logout-form:logout"))).click();
  public void testAgentLookup() {
    WebElement menu = new WebDriverWait(driver, 10).until(ExpectedConditions.elementToBeClickable("quick-link:jump-menu")));
    new Select(menu).selectByVisibleText("Agent Lookup");
    new WebDriverWait(driver, 10).until(ExpectedConditions.elementToBeClickable("zip-search:zipcode"))).sendKeys("78731");
    WebElement walker = new WebDriverWait(driver, 10).until(ExpectedConditions.presenceOfElementLocated(By.xpath("//div[text()='Walker']")));
    assertEquals("Walker", walker.getText());

Simply change the beforeClass method to not directly create a ChromeDriver object, but instead to create a Silk Test BrowserBaseState, to execute that new state, and to retrieve the WebDriver object from the resulting BrowserApplication object:

public static void beforeClass() {
  Desktop desktop = new Desktop();
  BrowserBaseState baseState = new BrowserBaseState();
  BrowserApplication app = baseState.execute(desktop);
  driver = app.getWebDriver();

That's all! Now you can run your tests through the Run as Silk4J Test… command of the context menu or you can launch configurations in Eclipse, and you will automatically get TrueLog files, including screenshots, if those are turned on in the Options.


That was easy! But what if you either don't want to use Eclipse or JUnit but you still have Java-based WebDriver tests for which you want to get TrueLog files? This is also no problem and will be the subject of another blog post, in which we will describe how you can create TrueLog files for TestNG tests that are triggered from IntelliJ.

  • Hi,  Based on my research, web driver capability is introduced only in SILK TEST 18. Can the above be done using SILK TEST 16.5 by  referencing the selenium javaclient bindings which I assume is selenium.-java-xxx.jar?

  • I am able to succeed running the selenium scripts in silk test 16.5 except for being able to display the truelog files

  • Hi!

    Unfortunately this won’t work with Silk Test 16.5, as the Selenium capabilities were introduced with Silk Test 18.0. You can of course run Selenium scripts within the context of your Silk4J project in Silk Test 16.5 as well, but you won’t have the advanced capabilities described in this post.

    Let me know if you have any further questions!