Changing the proxy server during Selenium
<p>So everything works</p>

<pre><code>fp = webdriver.FirefoxProfile()
fp.set_preference("network.proxy.type", 1)
fp.set_preference("network.proxy.http", PROXY_HOST)
fp.set_preference("network.proxy.http_port", int(PROXY_PORT))
fp.update_preferences()
driver = webdriver.Firefox(firefox_profile=fp)
</code></pre>

<p>But if the driver has already been created, the proxy can not install.
It does not work</p>

<pre><code>driver = webdriver.Firefox()
driver.profile.set_preference("network.proxy.type", 1)
driver.profile.set_preference("network.proxy.http", PROXY_HOST)
driver.profile.set_preference("network.proxy.http_port", int(PROXY_PORT))
driver.profile.update_preferences()
</code></pre>

<p>And so, too.</p>

<pre><code> driver = webdriver.Firefox()
 driver.firefox_profile.set_preference("network.proxy.type", 1)
 driver.firefox_profile.set_preference("network.proxy.http", PROXY_HOST)
 driver.firefox_profile.set_preference("network.proxy.http_port", int(PROXY_PORT))
 driver.firefox_profile.update_preferences()
</code></pre>

<p>Why? Can not understand.
I'm doing something wrong?</p>

<p>When using WebDriver with Firefox, the use of the profile is a one-time thing. When the driver launches the browser, it writes the profile object to disk, then starts the browser executable. After that point, there is no mechanism for the browser to read any further changes to the WebDriver profile object. To change the proxy, you have to set the settings in the profile before the browser is launched.</p>

python selenium selenium-webdriver proxy updates