Python selenium add https proxy, pythonselenium
I have been looking for how to use a proxy in automated testing. I am a little bit familiar with it. phantomjs chrome is a normal http proxy, and it will not work when https is used. I was depressed for three days. Later I referred to the document and switched to firforx to finally get started. I forgot to record the preparations.
Ip = "127.0.0.1" duankou = int (123456) # Remember to type conversion here, this pitfall step on 2 days profile = webdriver. firefoxProfile () profile. set_preference ('network. proxy. type ', 1) profile. set_preference ('network. proxy. http ', "% s" % ip) profile. set_preference ('network. proxy. http_port ', duankou) profile. set_preference ('network. proxy. ssl ', "% s" % ip) profile. set_preference ('network. proxy. ssl_port ', duankou) # profile. set_preference ('General. useragent. override ', uap) # sets the proxy header profile. update_preferences () driver = webdriver. firefox (firefox_profile = profile, executable_path = OS. getcwd () + '/driver/geckodriver.exe ')