0

我是 selenium 和 webdriver 的新手,经过我得到以下代码来设置代理并启动浏览器:

String PROXY = "<<MY proxy>>";
org.openqa.selenium.Proxy proxy = new org.openqa.selenium.Proxy();
proxy.setHttpProxy(PROXY);
DesiredCapabilities cap = new DesiredCapabilities();
cap.setCapability(CapabilityType.PROXY, proxy);
WebDriver driver = new InternetExplorerDriver(cap);
driver.get("http://www.google.com");        
driver.quit();

遇到以下问题:

1)得到下面附加的错误
2)我可以从 IE 代理设置中看到我提供的代理字符串存在于“proxy.pac”文件中,但代理不起作用。即使我停止脚本并手动执行
3)当我将代理字符串直接放在浏览器中时,它在我提供凭据后工作正常。我应该提供凭据吗?你能指导一下如何做吗?

Sep 5, 2012 3:59:52 PM org.openqa.selenium.browserlaunchers.WindowsProxyManager backupRegistrySettings
INFO: Backing up registry settings...
Sep 5, 2012 3:59:53 PM org.openqa.selenium.browserlaunchers.WindowsProxyManager      changeRegistrySettings
INFO: Modifying registry settings...
The path to the driver executable must be set by the webdriver.ie.driver system property; for more information, see   http://code.google.com/p/selenium/wiki/InternetExplorerDriver. The latest version can be downloaded from http://code.google.com/p/selenium/downloads/list
Sep 5, 2012 3:59:54 PM org.openqa.selenium.ie.InternetExplorerDriverServer initializeLib
WARNING: This method of starting the IE driver is deprecated and will be removed in selenium 2.26. Please download the IEDriverServer.exe from http://code.google.com/p/selenium/downloads/list and ensure that it is in your PATH.
Sep 5, 2012 3:59:58 PM org.apache.http.impl.client.DefaultRequestDirector tryExecute
INFO: I/O exception (org.apache.http.NoHttpResponseException) caught when processing request: The target server failed to respond
Sep 5, 2012 3:59:58 PM org.apache.http.impl.client.DefaultRequestDirector tryExecute
INFO: Retrying request
Picked up JAVA_TOOL_OPTIONS: -agentlib:jvmhook
Picked up _JAVA_OPTIONS: -Xrunjvmhook -Xbootclasspath/a:D:\bin\java_shared\classes;D:\bin\java_shared\classes\jasmine.jar
4

1 回答 1

2

你读过异常的内容吗?您的问题与代理无关。打开IE实例是个问题。您需要从 Selenium 的网站下载 IeDriverServer 并将其路径分配给 webdriver.ie.driver 属性。

您可以在其他主题中阅读有关它的更多信息:

驱动程序可执行文件必须由 webdriver.ie.driver 系统属性设置

如何设置 InternetExplorerDriver 以使其正常工作

于 2012-09-05T15:13:05.113 回答