简体   繁体   中英

NoMethodError: private method `browser_name' called for {:browserName=>:firefox, :version=>nil}:Hash

I am trying to learn selenium Grid, I followed a tutorial, but when I try to run my feature I got this error :

NoMethodError: private method `browser_name' called for {:browserName=>:firefox, :version=>nil}:Hash

here is the env.rb file :

   require 'watir-webdriver'
require 'cucumber'

def browser_path
  (ENV['BPATH'])
end

def browser_name
  (ENV['BROWSER'] ||= 'firefox').downcase.to_sym
end

def environment
  (ENV['ENV'] ||= 'grid').downcase.to_sym
end

def browser_version
  (ENV['VER'])
end

Before do
  def assert_it message, &block
    begin
      if (block.call)
        puts "Assertion PASSED for #{message}"

      else
        puts "Assertion FAILED for #{message}"
        fail('Test Failure on assertion')
      end
    rescue => e
      puts "Assertion FAILED for #{message} with exception '#{e}'"
      fail('Test Failure on assertion')
    end
  end
  if browser_path != nil
    Selenium::WebDriver::Firefox.path= "#{browser_path}"
  end
  if environment == :grid
    @browser = Watir::Browser.new(:remote, :url=>"http://10.196.60.38:4444/wd/hub", :desired_capabilities=> {browserName: browser_name,version: browser_version})
    @browser.window.maximize
  else
    @browser = Watir::Browser.new browser_name
    @browser.window.maximize
  end

end

After do
  @browser.close
end

Thanks, your help is appreciated.

watir-webdriver is deprecated and will not work with latest versions of Firefox. Please update to the latest version of watir .

Also with latest version of watir, you should be able to just do:

Watir::Browser.new(browser_name, url: "http://10.196.60.38:4444/wd/hub", version: browser_version

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM