Invoking supported Web Browsers via Silk4Net

Invoking supported Web Browsers via Silk4Net

To invoke a supported Web Browser via Silk4Net, the baseState class can used. As this class provides the method "BrowserType" for specifying the desired browser that must be started from the test method in question, for example the following function will start a browser based on the “BrowserType” passed into it:

 

Public Function StartBrowser(browseType As BrowserType) As BrowserApplication
       Dim baseState As New BrowserBaseState()
       baseState.BrowserType = browseType        
       Return baseState.Execute()
End Function

 

In the subsequent TestMethod we can then pass in the browser type of a supported browser such as “Internet Explorer” or “FireFox”

 

<TestMethod>
Public Sub TestAllBrowsers()
       Dim iE As BrowserApplication = StartBrowser(BrowserType.InternetExplorer)
       Dim fireFox As BrowserApplication = StartBrowser(BrowserType.Firefox)

       TestBrowser(iE)
       TestBrowser(fireFox)
End Sub

This is done by passing the browserType to the sub routine (TestBrowser) which then executes the Silk4NET calls:

 

Private Sub TestBrowser(browserApp As BrowserApplication)
       browserApp.SetActive()
       With browserApp
              With .BrowserWindow()
                     .DomButton("//INPUT[@name='bSubmit']").Click(MouseButton.Left, New Point(56, 13))
                     .DomTextField("//INPUT[@name='QTY_SHORTS']").Click(MouseButton.Left, New Point(36, 15))
                     .DomTextField("//INPUT[@name='QTY_SHORTS']").TypeKeys("1")
                     .DomButton("//INPUT[@name='bSubmit']").Click(MouseButton.Left, New Point(43, 0))
                     .DomButton("//INPUT[@name='bSubmit']").Click(MouseButton.Left, New Point(79, 16))
             End With
             .CloseSynchron()
      End With
End Sub

 

The following is an example Silk4NET Class created in VB.NET which demonstrates how to execute a test by inoking multiple browsers.

DISCLAIMER:

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-04-09 13:16
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.