我无法使用 Capybara 和 Selenium 与 Safari Technology Preview (STP) 建立 session 。 Capybara 甚至不会打开浏览器窗口。
我已经升级到 Ruby 2.3.0 Capybara 2.14.2 Selenium 3.4.0
我从 https://developer.apple.com/safari/download/ 下载并安装了 STP
我正在尝试使用以下代码:
Capybara.register_driver :selenium do |app|
Capybara::Selenium::Driver.new(
app,
browser: :safari
)
end
Capybara.default_driver = :selenium
如何初始化 Capybara 以使用已实现 W3C 自动化标准的 STP safaridriver?
最佳答案
为了让它工作,我使用了以下代码:
#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 - 如何在 Ruby 中使用 Safari Technology Preview 设置 Capybara,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44663481/