I'm trying to figure out how to route my requests through an HTTP proxy.
I'm initializing webdriver like this:
user_agent = 'my user agent 1.0' DesiredCapabilities.PHANTOMJS['phantomjs.page.settings.userAgent'] = user_agent driver = webdriver.PhantomJS()
I've gone through the docs and the source and can't seem to find a way to use a proxy server with phantomjs for through webdriver.
Any suggestions?
We can run a proxy with Selenium webdriver in Python. A proxy is an essential component to do localization testing. We can take an e-commerce application and check if the language and currency visible is as per the user location. Import webdriver from Selenium package.
PhantomJS is a headless Webkit, which has a number of uses. In this example, we'll be using it, in conjunction with Selenium WebDriver, for conducting basic system tests directly from the command line. Since PhantomJS eliminates the need for a graphical browser, tests run much faster.
Below is the example of how to set proxy for PhantomJs in Python. You may change proxy type: socks5/http.
service_args = [ '--proxy=127.0.0.1:9999', '--proxy-type=socks5', ] browser = webdriver.PhantomJS('../path_to/phantomjs',service_args=service_args)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With