Dashboard > Watir > ... > Watir Development > Browser.new
Watir Log In View a printable version of the current page.
Browser.new
Added by Bret Pettichord, last edited by Alister Scott on Jan 01, 2009  (view change)
Labels: 
(None)

Using Browser.new

With Watir 1.6 (currently in development), a new interface to Watir has been provided to make it easier to write tests that are portable across browsers.

With 1.6.0, it will support IE and Firefox (using FireWatir). With time, it will support additional browsers.

Updating Your Tests

In your tests, you should use

Watir::Browser.new
instead of
Watir::IE.new

Specifying Which Browser to Test

Instead of hard-coding the browser in your tests, you can now specify which browser should be tested at run time. There are several ways to do this.

Environment variable

> set watir_browser=ie
> set watir_browser=firefox
> set watir_browser=safari
>

This setting will determine which browser "Watir::Browser.new" will test.

Watir::Browser.default

You can specify what browser will be used directly in your Ruby code:

Watir::Browser.default = 'ie'

Config file

Create a file like this, called options.yml

browser: ie

In your program, execute the following code before calling "Watir::Browser.new":

Watir.options_file = 'c:/work/options.yml'

You will need to provide the full path to your file. Once you have done this, "Browser.new" will use the option settings from this file. If you also use an environment variable, it will override this setting.

Specifying additional options

Currently the following options are configurable for IE:

speed: fast
visible: true

Valid speed settings are "fast", "slow" and "zippy"

Compatibility

Watir 1.6.2 does not support Browser.attach. This will be supported in a future version.

For details on other compatibility issues with Watir's support for IE and Firefox, see Firewatir Compatibility

For consistency, should we allow users to specify speed in the ruby code as well?
For example:

Watir::Browser.speed = 'zippy'
Site running on a free Atlassian Confluence Community License granted to OpenQA. Evaluate Confluence today.
Powered by Atlassian Confluence, the Enterprise Wiki. (Version: 2.5.6 Build:#812 Aug 06, 2007) - Bug/feature request - Contact Administrators