How to change Firefox web driver proxy settings at runtime?

别说谁变了你拦得住时间么 提交于 2019-11-28 01:10:58

问题


I use Selenium 2.35.0 and configure proxy settings like:

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

driver = new FirefoxDriver(firefox, profile, cap);

When I need to change proxy settings I force to restart webdriver and speify other "proxyStr".

How I can reach this changing without of webdriver restart?


回答1:


When you set a proxy for any given driver, it is set only at the time WebDriver session is created; it cannot be changed at runtime. Even if you get the capabilities of the created session, you won't be able to change it. So the answer is, no, you must start a new session if you want to use different proxy settings.



来源:https://stackoverflow.com/questions/19565426/how-to-change-firefox-web-driver-proxy-settings-at-runtime

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!