[英]Selenium Tag Ruby Cucumber
I'm using Selenium-Webdriver with the ChromeDriver installed as well as PhantomJS to automate my test pack.我正在使用安装了 ChromeDriver 的 Selenium-Webdriver 以及 PhantomJS 来自动化我的测试包。 There are some scenarios that I would prefer to run in browser when my pack is running headless.当我的包无头运行时,有一些场景我更喜欢在浏览器中运行。 I can tag my scenario as @selenium
but when it loads, it opens up in firefox.我可以将我的场景标记为@selenium
但是当它加载时,它会在 Firefox 中打开。 How do I get it to open up ChromeDriver when using the @selenium tag please?请问如何在使用@selenium 标签时打开ChromeDriver?
I have the following in my env.rb file to run in browser:我的 env.rb 文件中有以下内容可在浏览器中运行:
if ENV['chrome']
Capybara.default_driver = :selenium
Capybara.register_driver :selenium do |app|
Capybara::Selenium::Driver.new(app,
:browser => :chrome,
desired_capabilities: {
"chromeOptions" => {
"args" => %w{ window-size=1080,720 }
}
}
) )
I set chrome=true to run in browser via cmd.我将 chrome=true 设置为通过 cmd 在浏览器中运行。
The solution, following on from Dave McNulla's guidance is as follows:根据 Dave McNulla 的指导,解决方案如下:
Before ('@tag') do |scenario|
Capybara.default_driver = :selenium
Capybara.register_driver :selenium do |app|
Capybara::Selenium::Driver.new(app,
:browser => :chrome,
desired_capabilities: {
"chromeOptions" => {
"args" => %w{ window-size=1080,720 }
}
}
)
end
end
I've set it to open in Chrome, only because it's default download action doesn't open up a pop up window, it goes directly to the downloads folder which is ideal for my tests.我将它设置为在 Chrome 中打开,只是因为它的默认下载操作不会打开弹出窗口,它直接进入下载文件夹,这是我测试的理想选择。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.