Webdriver和Firefox代理服务器

44

有没有办法设置Firefox的代理设置?我在这里找到了关于FoxyProxy的信息,但当Selenium工作时,窗口中的插件未被激活。

有没有办法设置Firefox的代理设置?我在这里找到了关于FoxyProxy的信息,但当Selenium工作时,窗口中的插件未被激活。

13个回答

0
FirefoxProfile profile = new FirefoxProfile();
String PROXY = "xx.xx.xx.xx:xx";
OpenQA.Selenium.Proxy proxy = new OpenQA.Selenium.Proxy();
proxy.HttpProxy=PROXY;
proxy.FtpProxy=PROXY;
proxy.SslProxy=PROXY;
profile.SetProxyPreferences(proxy);
FirefoxDriver driver = new FirefoxDriver(profile);

这是针对C#的


0

还有另一种解决方案,我寻找它是因为我在处理像这样的代码时遇到了问题(它在Firefox中设置系统代理):

FirefoxProfile profile = new FirefoxProfile();
profile.setPreference("network.proxy.http", "localhost");
profile.setPreference("network.proxy.http_port", "8080");
driver = new FirefoxDriver(profile);

我更喜欢这个解决方案,它强制在火狐浏览器中手动设置代理。 为了实现这个目的,可以使用org.openqa.selenium.Proxy对象来设置Firefox:
FirefoxProfile profile = new FirefoxProfile();
localhostProxy.setProxyType(Proxy.ProxyType.MANUAL);
localhostProxy.setHttpProxy("localhost:8080");
profile.setProxyPreferences(localhostProxy);
driver = new FirefoxDriver(profile);

如果它能帮助的话...


-4

首选项 -> 高级 -> 网络 -> 连接(配置 Firefox 如何连接到互联网)


我知道这个。当Selenium运行火狐浏览器窗口工作时,代理连接选项卡是空的。 - Max Frai

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接