如何在Ruby中使用Safari Technology Preview设置Capybara [英] How to setup Capybara with Safari Technology Preview in Ruby
问题描述
我无法使用Capybara和Selenium与Safari Technology Preview(STP)建立会话。水豚甚至都不会打开浏览器窗口。
I can't establish a session with Safari Technology Preview (STP) using Capybara and Selenium. Capybara won't even open a browser window.
我已经升级到Ruby 2.3.0 Capybara 2.14.2 Selenium 3.4.0
我是从> https://developer.apple.com/safari/download/
我正在尝试使用以下代码:
I've upgraded to Ruby 2.3.0 Capybara 2.14.2 Selenium 3.4.0
I downloaded and installed STP from https://developer.apple.com/safari/download/
I am trying to use the following code:
Capybara.register_driver :selenium do |app|
Capybara::Selenium::Driver.new(
app,
browser: :safari
)
end
Capybara.default_driver = :selenium
如何初始化Capybara以使用已实现W3C自动化标准的STP Safari驱动程序?
How do I initialize Capybara to use the STP safaridriver that has implemented the W3C standards for automation?
推荐答案
要使其正常工作,我使用了以下代码:
To get this to work I used the following code:
#This is what we use to test the Safari release channel.
#You will have to install Safari Technology Preview (STP) from Apple.
#see standard properties here: https://www.w3.org/TR/webdriver/#capabilities
#STP requires a capabilities object
#you could use any of the properties from the link above.
#I just used a accept_insecure_certs for the heck of it
desired_caps = Selenium::WebDriver::Remote::Capabilities.safari(
{
accept_insecure_certs: true
}
)
Capybara.register_driver :safari_technology_preview do |app|
Capybara::Selenium::Driver.new(
app,
browser: :safari,
driver_path: '/Applications/Safari Technology Preview.app/Contents/MacOS/safaridriver',
desired_capabilities: desired_caps
)
end
Capybara.default_driver = :safari_technology_preview
这篇关于如何在Ruby中使用Safari Technology Preview设置Capybara的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!