Using Selenium with Existing Silk4J Scripts

Note: The functionality described in this topic requires Java 8 or later.

To add WebDriver functionality to an existing Silk4J script, you can create a mixed script. To create such a mixed script, use the Open Agent as a Selenium server which is activated when a Silk4J base state is executed.

  1. Add the Silk Test Selenium Client Library to the project that contains the Silk4J script.
    1. In the Package Explorer, right-click on the project node.
    2. Select Silk4J Tools > Add WebDriver Capability.
  2. Open the Silk4J script.
  3. Retrieve the WebDriver ID of the browser instance that you want to refer to:
    BrowserApplication browserApplication = desktop.find("//BrowserApplication");
    WebDriver driver = browserApplication.getWebDriver();
    Note: If you want to test a hybrid application, use the following code:
    BrowserWindow browserWindow = desktop.find("//BrowserWindow");
    WebDriver driver = browserWindow.getWebDriver();
You can now use the RemoteWebDriver object in the same way as when you are using standalone Selenium. For example:
driver.get("http://demo.borland.com/InsuranceWebExtJS/");
driver.findElementById("login-form:login");
When you execute the script, all Selenium and Silk4J actions, along with any screenshots and parameters, are logged to the TrueLog.