SetBrowserType Function

Action

Sets the current browser type.

Availability

This functionality is supported only if you are using the Classic Agent. For additional information, refer to the Silk Test Classic Classic Agent Help.

Syntax

OldBrowserType = SetBrowserType (NewBrowserType [,hMachine])
Variable Description
OldBrowserType The previous browser type. BROWSERTYPE.
NewBrowserType The new browser type. BROWSERTYPE or NULL.
hMachine Optional: Machine on which to set the browser type. Default is the current machine. HMACHINE.

Notes

SetBrowserType sets the current browser type on the current machine or on a specified machine to NewBrowserType or NULL (no browser) and returns the previous browser type. SetBrowserType does not change the value set for Default Browser in Runtime Options.

Note: When you are using the Open Agent, you can check the browser type of the currently used browser application window by querying the property browsertype. For additional information, see How Can I See Which Browser I Am Currently Using?. However, the browsertype property cannot be set, since this is given by the browser. To ensure that you are testing a specific browser type, you can either change your application configuration or start the specific browser using the base state.

Example

Assume Internet Explorer 7.0 is the current browser when the following code is run:

BROWSERTYPE btOldType
btOldType = SetBrowserType (explorer8_0)
Print ("Old type: {btOldType}")
Print ("New type: {GetBrowserType()}")

// Result:
// Old type: Internet Explorer 7.0
// New type: Internet Explorer 8.0