rubywatirpage-object-gem

how to specify driver path in ruby watir 7?


While am specifying driver path in watir 7 it throws below error How to specify driver path please help

browser_opts = {driver_path: 'C:/software/SELENIUM-DRIVERS/chromedriver.exe'}

Before do
  @browser = Watir::Browser.new :chrome, browser_opts
  @browser.window.maximize
end

      {:driver_path=>"C:/software/SELENIUM-DRIVERS/chromedriver.exe"} are unrecognized arguments for Browser constructor
 (ArgumentError)
      ./features/support/hooks.rb:8:in `new'
      ./features/support/hooks.rb:8:in `Before'

Solution

  • The driver path needs to be part of the service options rather than the browser options.

    This would look like:

    opts = {service: {path: 'C:/software/SELENIUM-DRIVERS/chromedriver.exe'}}
    
    browser = Watir::Browser.new(:chrome, opts)