【问题标题】:Selenium_Webdriver: Proxy settingSelenium_Webdriver:代理设置
【发布时间】:2012-08-30 01:43:15
【问题描述】:

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

【问题讨论】:

    标签: java selenium-webdriver


    【解决方案1】:

    您是否阅读过异常的内容?您的问题与代理无关。打开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

    【讨论】:

    • 我在尝试了其他选项后发布了这个:(当我尝试下面的代码时:
    • 代码:代理 proxy = new Proxy(); proxy.setHttpProxy("setproxy.gsk.com//proxy.pac"); 文件 file = new File("D:\\Selenium\\IEDriverServer.exe"); System.setProperty("webdriver.ie.driver", file.getAbsolutePath()); 驱动= new InternetExplorerDriver(); baseUrl = "google.co.uk"; 错误:监听端口 15959 拾取 JAVA_TOOL_OPTIONS: -agentlib:jvmhook 拾取 _JAVA_OPTIONS: -Xrunjvmhook -Xbootclasspath/a:D:\bin\java_shared\classes;D: \bin\java_shared\classes\jasmine.jar;'-Dname=javahowto' 奇怪的是,浏览器打开了 url “Www.cfauth.com”
    猜你喜欢
    • 2019-04-18
    • 1970-01-01
    • 2017-06-09
    • 2016-10-18
    • 2021-12-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多