2012-01-12 53 views
6

我不想给出代理的用户名/密码设定我有我的办公网络,我可以给代理的浏览器之一:如何为代理包含代理授权用户名和密码?

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驱动程序的用户名/密码。请帮忙!

+0

寻求专家的帮助... – 2012-01-15 10:28:55

+0

我觉得你,我试图找到答案,但没有运气。 @Bijoy,已经有一个月了,你有没有想过要怎么做?希望你能帮助我。 – Shane 2012-03-03 12:29:44

+0

在当前webdriver(使用firefox驱动程序)中完成它的唯一方法是在firefox配置文件中设置它们,然后使用该配置文件作为启动webdriver的源配置文件。我实际上必须修补硒才能在运行时设置它们。我希望能够提取补丁并在接下来的几天发布它们 – 2012-03-15 14:01:55

回答

0

试试下面

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

我看了很多帖子,说明你必须发送轮廓为Base64编码字符串。

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

我读过的文档从来没有确定过,如果这是必要的,但它值得一试。

相关问题