Unable to connect to browser using ruby selenium webdriver

后端 未结 3 1996
名媛妹妹
名媛妹妹 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:52

    You probably have HTTP_PROXY (or http_proxy) set in your environment. The next release of selenium-webdriver (2.25) will also honor NO_PROXY/no_proxy (which you can then set to NO_PROXY=127.0.0.1). Until then you can remove the proxy from the Ruby environment before launching the browser:

    ENV['HTTP_PROXY'] = ENV['http_proxy'] = nil
    driver = Selenium::WebDriver.for :firefox
    

    If you need the proxy configured for Firefox to communicate with the outside world, you could try something like this:

    proxy = Selenium::WebDriver::Proxy.new(:http => ENV['HTTP_PROXY'] || ENV['http_proxy'])
    ENV['HTTP_PROXY'] = ENV['http_proxy'] = nil
    driver = Selenium::WebDriver.for :firefox, :proxy => proxy
    

提交回复
热议问题