I've been trying to get PhantomJS to set custom user agent, meanwhile using the proxy with authentication. Basically, I have 2 cases that I absolutely need.
1.) To be able to use custom User Agent.
2.) To be able to make connection via authenticated proxy.
I've gone through other SO posts like THIS & THIS. I've tried using PhantomJS 2.1.1 and 1.9.8. Nothing worked. Here's my code for PhantomJS Selenium (Python).
Here's my code on REPL : https://repl.it/@Xonshiz/seleniumIssue
So, I've tried 3 things and all 3 come with their own issues.
1.) PhantomJS : I'm able to use authenticated proxy. But, seems like my browser's user agent string isn't being changed. I checked the capabilities
, it looks fine. But, when I execute driver.execute_script("return navigator.userAgent")
. It shows me that it's still "PhantomJS". I've tried all the ways I could find on SO and github issues. Nothing worked.
2.) Google Chrome : Chrome can set User-Agent, but can't take in proxies. After tryign multiple ways and failing, I came across some answer on SO itself, which mentioned that Chrome doesn't use any separate proxy and uses "System Proxy" only (Much like INTERNET EXPLORER)!. I don't want to change my system's proxy for this. It's a poor solution.
3.) Firefox : At last, I tried firefox. It comes with its own issues for Proxy. I can't seem to pass any kind of proxy information to Firefox. I tried using a simple proxy without any authentication and seems like that won't work.
I'm stuck at these 3 things. If anyone could help me with this issue, it would be great. I'm open to using FF or Chrome, as long as they work with authenticated proxies (No system wide proxy). I'll be happy to switch and use them.