How to specify installation of Firefox to use for watir-webdriver script execution
Asked Answered
R

3

5

For testing purposes I have multiple Firefox installations/versions on one machine made by using Utilu FF collection.

If there`s

b = Watir::Browser.new :ff

in test script, it is automatically executed with oldest FF version which is 3.6.22 in my case. I was surprised, because I assumed that by default script will be executed in Windows default browser which is Firefox6 not Firefox 3.6.22.

How to specify which installation/version of Firefox must be used for Watir-webdriver test script execution?

Ravelment answered 8/9, 2011 at 10:12 Comment(0)
A
8

You can specify a path to your firefox executable:

require 'watir-webdriver'
Selenium::WebDriver::Firefox.path = "/path/to/firefox.exe"
b = Watir::Browser.new :firefox
Argentic answered 9/9, 2011 at 1:11 Comment(4)
It appears that it`s better to put path to Firefox in single quotes to avoid "Invalid escape character syntax" error.Ravelment
I recieved errors when executing script C:/Ruby192/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.5.0/lib/selenium/webdriver/common/driver.rb:43:in for': unknow n driver: :Firefox (ArgumentError) from C:/Ruby192/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.5.0/lib/selenium/webdriver.rb:81:in for' from C:/Ruby192/lib/ruby/gems/1.9.1/gems/watir-webdriver-0.3.2/lib/watir-webdriver/browser.rb:35:in initialize' from C:/Users/user/Documents/test1.rb:5:in new' from C:/Users/user/Documents/test1.rb:5:in `<main>'Ravelment
:firefox is case sensitive, therefore must be lowercaseArgentic
@AlisterScott, similar to Selenium::WebDriver::Firefox.path, is there a way to modify the firefox parameters used when launched internally? Specifically I'm trying to remove --no-remoteJaneljanela
T
2

For those using chromedriver use:

Selenium::WebDriver::Chrome.driver_path = "path/to/chromedriver"
Tudela answered 6/11, 2013 at 10:10 Comment(0)
A
0

For phantomjs:

Selenium::WebDriver::PhantomJS.path="/usr/bin/phantomjs"
Antiphon answered 30/1, 2015 at 20:43 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.