无法使用ruby selenium webdriver连接到浏览器
发布时间:2020-12-16 21:47:14 所属栏目:百科 来源:网络整理
导读:我尝试使用 ruby selenium webdriver运行一些基本的自动化测试.相同的代码在我的家用电脑上完美工作,但在我的工作计算机上(在代理服务器后面(不需要身份验证))中失败. driver = Selenium :: WebDriver.for:firefox,:profile = ‘默认’ 我得到的错误是: C
我尝试使用
ruby selenium webdriver运行一些基本的自动化测试.相同的代码在我的家用电脑上完美工作,但在我的工作计算机上(在代理服务器后面(不需要身份验证))中失败.
driver = Selenium :: WebDriver.for:firefox,:profile => ‘默认’ 我得到的错误是: C:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.24.0/lib/selenium/webdriver/remote/http/common.rb:66:in `create_response': unexpected response,code= 403,content-type="text/html" (Selenium::WebDriver::Error::WebDriverError) <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <HTML><HEAD><META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1"> <TITLE>ERROR: The requested URL could not be retrieved</TITLE> <STYLE type="text/css"><!--BODY{background-color:#ffffff;font-family:verdana,sans-serif}PRE{font-family:sans-serif}--></STYLE> </HEAD><BODY> <H1>ERROR</H1> <H2>The requested URL could not be retrieved</H2> <HR noshade size="1px"> <P> While trying to retrieve the URL: <A HREF="http://127.0.0.1:7055/hub/session">http://127.0.0.1:7055/hub/session</A> <P> The following error was encountered: <UL> <LI> <STRONG> Access Denied. </STRONG> <P> Access control configuration prevents your request from being allowed at this time. Please contact your service provider if you feel this is incorrect. </UL> 浏览器打开正确的配置文件,但导致的驱动程序变量为零.我甚至试图在配置文件上手动设置代理,没有运气. 有任何想法吗 ? 解决方法
您可能在您的环境中设置了HTTP_PROXY(或http_proxy). selenium-webdriver(2.25)的下一个版本也将遵循NO_PROXY / no_proxy(您可以将其设置为NO_PROXY = 127.0.0.1).在此之前,您可以在启动浏览器之前从Ruby环境中删除代理:
ENV['HTTP_PROXY'] = ENV['http_proxy'] = nil driver = Selenium::WebDriver.for :firefox 如果您需要为Firefox配置的代理与外界通信,可以尝试以下方式: 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 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容