1
votes

We have moved away from watir-webdriver(IE) to watir-classic (we found it to be faster and more 'forgiveable' when searching from elements...(atleast on win7-64bit IE9).

So we decided to move to watir 4.+ (to take advantage of the automatic 'require switching'), so now our common scripts are now working on IE, BUT I cant seem to get firefox to load the customized profile... (1 example use of profile attached below)

I google'd but couldnt find an example that uses the watir 4.0 with firefox profile. Please help.

C:>ruby -v

ruby 1.9.3p385 (2013-02-06) [i386-mingw32]

C:>gem list | grep 'watir'

commonwatir (4.0.0)

watir (4.0.2 x86-mingw32)

watir-classic (3.7.0)

watir-webdriver (0.6.4)

C:>irb

irb(main):001:0> require 'watir'

=> true

irb(main):002:0> profile = Selenium::WebDriver::Firefox::Profile.new

    NameError: uninitialized constant Selenium

    from (irb):2

    from C:/Ruby193/bin/irb:12:in `<main>'

irb(main):003:0> ^C

irb(main):003:0>

Terminate batch job (Y/N)? Y

C:>irb

irb(main):001:0> require 'watir-webdriver'

=> true

irb(main):002:0> profile = Selenium::WebDriver::Firefox::Profile.new

=> #

irb(main):003:0> profile['network.http.phishy-userpass-length'] = 255

=> 255

irb(main):004:0> driver = Selenium::WebDriver.for(:firefox, :profile => profile)

=> #

irb(main):005:0> browser = Watir::Browser.new(driver)

=> #

irb(main):006:0> ^C

irb(main):006:0> Terminate batch job (Y/N)? Y

1

1 Answers

2
votes

I do not believe that the watir loader handles that situation. You could log it as an issue and see if there is a good way to address it.

In the short term, you could force watir-webdriver (and therefore selenium-webdriver) to be loaded when creating the profile.

require 'watir'
Watir.driver = 'webdriver'
Watir.load_driver

profile = Selenium::WebDriver::Firefox::Profile.new
profile['network.http.phishy-userpass-length'] = 255

browser = Watir::Browser.new :chrome, :profile => profile