BROWSERTYPE Data Type

Description

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

Silk Test Classic supports different Web browsers and uses "browser specifiers" so that you can explicitly specify a particular browser in a script. The following table lists the most commonly used browser specifiers.

For information about new features, supported platforms, and tested versions, refer to the Release Notes.

Browser Specifier Browser
explorer Set that includes the following browser versions:
  • Internet Explorer 6
  • Internet Explorer 7
  • Internet Explorer 8
explorer6_DOM Internet Explorer 6
explorer7 Internet Explorer 7
explorer8_0 Internet Explorer 8
explorer_DOM Set that includes the following browser versions:
  • Internet Explorer 6
  • Internet Explorer 7
  • Internet Explorer 8
Note: "explorer_DOM" is identical with "explorer" and exists only for backward compatibility.
firefox Set that includes the following browser versions:
  • Mozilla Firefox 1.5
  • Mozilla Firefox 2.0
firefox1_5 Mozilla Firefox 1.5
firefox2_0 Mozilla Firefox 2.0

Notes

You can use a browser specifier in a script in two ways:

  • You can use a browser specifier in a script or include file to indicate that a particular line applies only to particular browsers.
  • You can pass a browser specifier to the SetBrowserType or SetDefaultBrowserType function to specify a browser that you want your test to run against. (You cannot use the browser specifiers explorer and firefox this way.)

You set the browser in the Runtime Options dialog box or by calling the SetBrowserType or SetDefaultBrowserType function, each of which takes an argument of type BROWSERTYPE. If you do not set a browser type explicitly in a script, Silk Test Classic uses the browser specified in the Runtime Options dialog box.

If you try to use a browser specifier instead of a GUI specifier to specify a window, Silk Test Classic generates an error. The primary use of browser specifiers is to address differences in window declarations between different browsers. Each Agent connection maintains its own browser type, allowing different threads to interact with different browsers.

Note: When you are using the Open Agent, you can get or set the browser type by using the GetProperty and SetProperty methods of the AnyWin class on the BrowserApplication. For example:
browserApplication.getProperty("browsertype")

Syntax

A browser specifier has the following syntax:

[[browser-type [, browser-type]...] | [! browser-type]]

For example, you can specify one or more browser types separated by commas, such as:

firefox, explorer

You can also specify all but one browser, such as the following, which indicates that what follows applies to all browsers except Firefox:

! firefox

Example 1

In the following code fragment, Mozilla Firefox and Internet Explorer browser specifiers are used to indicate that the tag for the BrowserAuthentication window differs in the two browsers.

Note: Browser specifiers can be used in conjunction with GUI specifiers as well.
[-] window DialogBox BrowserAuthentication
	[ ] explorer, msw2000 tag "Enter Network Password"
	[ ] explorer, mswxp tag "Authentication"
	[ ] explorer, msw2003 tag "Basic Authentication"

Example 2

The test case in the next example (GetItemCount) takes an argument of type BROWSERTYPE, allowing you to pass browser specifiers at runtime. (The test case uses the recovery system and assumes that wMainWindow is set to the GMO Web application's Welcome page, whose identifier is GMO.)

This example uses the main function to pass the arguments. For more information on passing data to a test case, see the example on generalizing test cases.

[-]  main ()
	[ ]  LIST OF BROWSERTYPE lbtType
	[ ]  BROWSERTYPE btType
	[ ]  lbtType = {explorer7, firefox1_5}
	[-]  for each btType in lbtType
		[ ]  GetItemCount (btType)
	[ ] 
[-] testcase GetItemCount (BROWSERTYPE btType)
	[ ] GMO.About.Click ()
	[ ] INTEGER iCount
	[ ] iCount = AboutPage.UsedList.GetItemCount ()
	[ ] Print (btType)
	[ ] Print ("Item count: {iCount}")
	[ ] 
	[ ] // Results:
	[ ] // Testcase GetItemCount (explorer7) - Passed
	[ ] // Internet Explorer 7.0
	[ ] // Item count: 9
	[ ] // Testcase GetItemCount (firefox1_5) - Passed
	[ ] // Mozilla Firefox 1.5
	[ ] // Item count: 9
Note: In the preceding test case, you do not have to call SetBrowserType to set the browser type. If a BROWSERTYPE argument is passed to a test case, the recovery system automatically calls SetBrowserType with the argument.