Unable to connect to browser using ruby selenium webdriver

后端 未结 3 1974
名媛妹妹
名媛妹妹 2021-01-02 05:01

I tried to run some basic automated tests using ruby selenium webdriver. The same code works perfectly on my home computer, but fails on my work computer which is behind a p

3条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-01-02 05:32

    Usage of selenium-webdriver behind proxy has browser related specific. In short, you need to find a way of passing proxy settings to the browser instance created by webdriver.

    Below is a code that works with Firefox.

    #Firefox keeps proxy settings in profile.
    profile = Selenium::WebDriver::Firefox::Profile.new
    profile.proxy = Selenium::WebDriver::Proxy.new( :http => "192.168.1.1:3128")
    driver = Selenium::WebDriver.for :firefox, :profile => profile
    
    driver.navigate.to "http://google.com"
    puts driver.title
    driver.quit
    

提交回复
热议问题