无法使用Ruby Selenium WebDriver连接到浏览器
我尝试使用rubyseleniumwebdriver运行一些基本的自动化测试。相同的代码在我的家用计算机上可以完美地工作,但是在我的工作计算机上却无法工作,而我的工作计算机位于代理后面(不需要身份验证)。
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
-
如何使用相同的浏览器窗口使用selenium-webdriver(ruby)进行自动测试?
2021-02-01 关注 0 浏览319 1答案
-
我如何重新连接使用selenium的webdriver打开的浏览器?
2021-02-01 关注 0 浏览97 1答案
-
使用Selenium WebDriver获取浏览器版本
2021-02-01 关注 0 浏览114 1答案
-
使用Java使用Selenium WebDriver捕获浏览器日志
2021-02-01 关注 0 浏览407 1答案
-
使用Selenium WebDriver Java绑定清除浏览器Cookies
2021-02-01 关注 0 浏览124 1答案
-
Selenium无头浏览器WebDriver [Errno 104]对等重置连接
2021-02-01 关注 0 浏览76 1答案
-
cucumber; Selenium WebDriver-如何使用Google Chrome浏览器代替Firefox作为测试浏览器
2021-02-01 关注 0 浏览131 1答案
-
如何使用Selenium WebDriver打开特定的浏览器
2021-02-01 关注 0 浏览129 1答案
-
selenium.common.exceptions.WebDriverException:消息:打开chrome浏览器时无法连接到服务chromedriver.exe
2021-02-01 关注 0 浏览112 1答案
-
Microsoft Edge浏览器是否可以使用Selenium WebDriver?
2021-02-01 关注 0 浏览107 1答案