Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby 未初始化的常量Selenium::WebDriver::Chrome::Options您的意思是什么?Selenium::WebDriver::Options(名称错误)_Ruby_Selenium_Cucumber - Fatal编程技术网

Ruby 未初始化的常量Selenium::WebDriver::Chrome::Options您的意思是什么?Selenium::WebDriver::Options(名称错误)

Ruby 未初始化的常量Selenium::WebDriver::Chrome::Options您的意思是什么?Selenium::WebDriver::Options(名称错误),ruby,selenium,cucumber,Ruby,Selenium,Cucumber,最近我浏览了chrome无头浏览器selenium automation。我在ruby中使用Selenium cucumber。现在我想用Selenium::WebDriver::chrome::Options在chrome无头模式下运行我的整个项目 我更新了selenium webdriver、chrome驱动程序,我的chrome版本是61.0.3163.100 为了了解它的工作原理,我使用以下代码创建了test.rb: require "selenium-webdriver" #conf

最近我浏览了chrome无头浏览器selenium automation。我在ruby中使用Selenium cucumber。现在我想用Selenium::WebDriver::chrome::Options在chrome无头模式下运行我的整个项目

我更新了selenium webdriver、chrome驱动程序,我的chrome版本是61.0.3163.100

为了了解它的工作原理,我使用以下代码创建了test.rb:

require "selenium-webdriver"

#configure the driver to run in headless mode
options = Selenium::WebDriver::Chrome::Options.new
options.add_argument('--headless')
options.add_argument('--disable-gpu')
driver = Selenium::WebDriver.for :chrome, options: options
driver.get('http://stackoverflow.com/')
puts driver.title    
driver.quit
我得到的答复如下:

>>ruby test.rb
[1012/112029.980:ERROR:devtools_http_handler.cc(786)]
DevTools listening on 127.0.0.1:12703

 Stack Overflow - Where Developers Learn, Share, & Build Careers
现在,当我得到正确的响应时,我想配置驱动程序以无头模式运行我的项目

因此,我编辑了support文件夹的env.rb文件:

导入需要“selenium webdriver”,并编辑了下面创建驱动程序实例的部分:

else # else create driver instance for desktop browser
  begin
options = Selenium::WebDriver::Chrome::Options.new
options.add_argument('headless')
options.add_argument('--disable-gpu')
driver = Selenium::WebDriver.for :chrome, options: options
driver.get('http://stackoverflow.com/')
puts driver.title
  rescue Exception => e
    puts e.message
    Process.exit(0)
  end
end
我运行了命令>>cucumber BROWSER=chrome

uninitialized constant Selenium::WebDriver::Chrome::Options
Did you mean?  Selenium::WebDriver::Options

请帮助我解决这个问题,以及如何在无头模式下运行我的整个硒黄瓜项目?

我希望您拥有最新的硒宝石?是的,Tarun,我有最新的selenium gems,正如我提到的,当我试图在selenium Cumber项目的env.rb中添加代码时,我能够通过ruby文件获得输出。我希望您有最新的selenium gems?是的,Tarun,我有最新的selenium gems,正如我提到的,当我试图在selenium Cumber项目的env.rb中添加代码时,我能够通过ruby文件获得输出,并给出错误。