簡體   English   中英

NoMethodError:調用{:browserName =>:firefox,:version => nil}的私有方法“ browser_name”:哈希

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

我正在嘗試學習Selenium Grid,我遵循了一個教程,但是當我嘗試運行功能時,出現此錯誤:

NoMethodError:調用{:browserName =>:firefox,:version => nil}的私有方法“ browser_name”:哈希

這是env.rb文件:

   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

謝謝,感謝您的幫助。

watir-webdriver已棄用,不適用於最新版本的Firefox。 請更新到最新版本的watir

同樣,使用最新版本的watir,您應該可以做到:

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM