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
instead of
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
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: