Invoking supported Web Browsers via Silk4J

Invoking supported Web Browsers via Silk4J

To invoke a supported Web Browser via Silk4J, the BrowserBaseState class can used. The said class provides the method "setBrowserType" for specifying the desired browser that must be started from the test method in question, for example:

BrowserBaseState startIE = new BrowserBaseState();

To successfully invoke an instance of Internet Explorer, we must execute the BrowserBaseState as follows:


Therefore using the above information, to invoke all supported Browser types via Silk4J the following code can be used:

//Start Internet Explorer
BrowserBaseState ieBase = new BrowserBaseState();
BrowserApplication bIE = (BrowserApplication)ieBase.execute(desktop);

//Start Firefox
BrowserBaseState ffBase = new BrowserBaseState();
BrowserApplication bFF = (BrowserApplication)ffBase.execute(desktop);

//Start Chrome
BrowserBaseState gcBase = new BrowserBaseState();
BrowserApplication bGC = (BrowserApplication)gcBase.execute(desktop);

In the code above, a reference to each browser that has been invoked has been stored in the following variables:

  • bIE
  • bFF
  • bGC

These variables could be used to target automation code to execute against each running browser, via re-usable automation methods that perform common functionality across the browsers. For example, to navigate each browser to a specified URL, the following re-usable automation method that performs this functionality could be used:

public void navigateToURL(BrowserApplication browserType, String sURL){

To then navigate each browser to a specified URL using the above method, the following statements can be executed from the test method:

navigateToURL(bIE, "");
navigateToURL(bFF, "");
navigateToURL(bGC, "");


Some content on Community Tips & Information pages is not officially supported by Micro Focus. Please refer to our Terms of Use for more detail.
Top Contributors
Version history
Revision #:
1 of 1
Last update:
‎2013-03-13 08:22
Updated by:
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.