2017-06-20 50 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