How to change Firefox web driver proxy settings at runtime?
Asked Answered
S

1

6

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?

Sachs answered 24/10, 2013 at 12:3 Comment(3)
you can try - RemoteWebDriver#getCapabilities() and the cast Capabilities object it to DesiredCapabilities and set your new proxy to DesiredCapabilities#setCapability, load the urlPesce
I didn't use RemoteWebDriver. I use WebDriver.Sachs
RemoteWebDriver is parent class of WebDriver my friendPesce
H
10

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.

Hubby answered 24/10, 2013 at 13:2 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.