【问题标题】:How to include proxy auth username and password for proxy?如何包含代理的代理身份验证用户名和密码?
【发布时间】:2012-01-12 18:59:42
【问题描述】:

我不想为我的办公室网络提供代理设置的用户名/密码,我可以将代理提供给浏览器:

String PROXY = "localhost:8080";

org.openqa.selenium.Proxy proxy = new org.openqa.selenium.Proxy();
proxy.setHttpProxy(PROXY)
     .setFtpProxy(PROXY)
     .setSslProxy(PROXY);
DesiredCapabilities cap = new DesiredCapabailities();
cap.setPreference(CapabilityType.PROXY, proxy);

user_pref("network.proxy.http", "127.0.0.1");
user_pref("network.proxy.http_port", 8084);
user_pref("network.proxy.ssl", "127.0.0.1");
user_pref("network.proxy.ssl_port", 8084);
user_pref("network.proxy.no_proxies_on", "localhost:4444");
user_pref("network.proxy.type", 1);

但是,无论我做什么,它仍然要求 Webdriver 的密码。 注意:我可以发送 htmlunit 驱动程序的用户名/密码。请帮忙!

【问题讨论】:

  • 寻求专家帮助...
  • 我对你有感觉,我也在努力寻找答案,但还没有运气。 @Bijoy,已经一个月了,你知道怎么做吗?希望你能帮助我。
  • 在当前 webdriver(使用 firefox 驱动程序)中执行此操作的唯一方法是将这些设置在 firefox 配置文件中,然后使用该配置文件作为启动 webdriver 的源配置文件。实际上,我必须修补 selenium 才能在运行时设置它们。我希望能够在接下来的几天内提取补丁并发布它们
  • 现在有什么办法吗?

标签: selenium-webdriver


【解决方案1】:

试试下面

 FirefoxProfile profile = new FirefoxProfile(); 
 profile.setPreference("network.proxy.type", 0); 
 WebDriver driver = new FirefoxDriver(profile);

【讨论】:

    【解决方案2】:

    我已经阅读了很多帖子,说明您必须将配置文件作为 base64 编码字符串发送。

    cap.setPreference(CapabilityType.PROXY, proxy.ToBase64String());
    

    我读过的文档还没有确定是否需要这样做,但值得一试。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-02-15
      • 2016-11-13
      • 1970-01-01
      • 2013-08-25
      • 2011-03-18
      • 2012-10-07
      • 1970-01-01
      相关资源
      最近更新 更多