Python selenium add https proxy, pythonselenium

Source: Internet
Author: User

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 ')

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.