Selenium Webdriver:代理设置

时间:2012-09-05 10:46:54

标签: java selenium-webdriver

我是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

1 个答案:

答案 0 :(得分:2)

您是否阅读过例外情况?您的问题与代理无关。这是打开IE实例的问题。您需要从Selenium的网站下载IeDriverServer并将其路径分配给webdriver.ie.driver属性。

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

Driver executable must be set by the webdriver.ie.driver system property

How do I setup the InternetExplorerDriver so it works