2012-09-05 124 views
0

我一個新的硒和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 

回答

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

+0

我張貼這種嘗試其他選擇:(後,當我嘗試下面的代碼: – Kumar

+0

代碼: Proxy proxy = new Proxy(); proxy.setHttpProxy(「http://setproxy.gsk.com//proxy.pac」); File file = new File(「D:\\ Selenium \\ IEDriverServer.exe」 ); System.setProperty(「webdriver.ie.driver」,file.getAbs olutePath()); driver = new InternetExplorerDriver(); baseUrl =「http://www.google.co.uk/」; 錯誤: 偵聽端口15959個 拿起JAVA_TOOL_OPTIONS:-agentlib:jvmhook 拿起_JAVA_OPTIONS:-Xrunjvmhook -Xbootclasspath /一個:d:\ BIN \ java_shared \類; d:\ BIN \ java_shared \類\ jasmine.jar ;' - Dname = javahowto' 奇怪的是,瀏覽器打開URL「Www.cfauth.com」 – Kumar