Change proxy settings while chrome is initiliazed

Issue

I have a bunch of questions, please answer them or any known

Question 1:

How to change proxy settings after chrome has been launched?

Reason:

Infact, what I want is, I can’t wait for chrome to relaunch to change proxy setting everytime, I want some code to be injected in inspect or use any selenium driver method for changing proxy
this is possible in normal chrome using extensions but chromedriver can’t click on extension also it is not the most convenient way as my vpn does not have chrome extension

Question 2:

Is it possible to add a list of proxies to auto rotate for every website open?

Question 3:

Is it possible to run each chrome tab with seperate ip/proxy?

Question 4:

Can you tell me what matters the most running chrome flawlessly, multi-instances
i.e, I want to run multiple tests at once maybe 100s, my RAM is 16gb but computer still become slow due to more instances, CPU i5 8th gen

Solution

(1) Use like this

from selenium import webdriver
PROXY = "11.456.448.110:8080"
chrome_options = WebDriver.ChromeOptions()
chrome_options.add_argument('--proxy-server=%s' % PROXY)
chrome = webdriver.Chrome(chrome_options=chrome_options)
chrome.get("https://www.google.com")

(2)

Is it possible to add a list of proxies to auto rotate for every website open?

Yes and No. You must initialize new WebDriver instance. Yes, create new WebDriver instance, then open your web-page. No. You cannot change proxy after a WebDriver instance opened.

(3)

Is it possible to run each chrome tab with seperate ip/proxy?

No.

(4)

Can you tell me what matters the most running chrome flawlessly, multi-instances i.e, I want to run multiple tests at once maybe 100s, my RAM is 16gb but computer still become slow due to more instances, CPU i5 8th gen

Init many WebDriver, then put inside Python threads.

See

Answered By – James Graham

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published