2017-06-20 46 views
0

我无法使用Capybara和Selenium与Safari技术预览(STP)建立会话。水豚甚至不会打开浏览器窗口。如何在Ruby中使用Safari技术预览设置水豚

我已经升级到Ruby 2.3.0水豚2.14.2硒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使用STP safaridriver实现了W3C自动化标准?

回答

1

为了得到这个工作,我用下面的代码:

#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 :selenium 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 = :selenium