1

I am trying to change the useragent of phantomjs using selenium on Python. No matter what I try, it is just not working. Following is the code that is supposed to work...

    dcap = dict(DesiredCapabilities.PHANTOMJS)
    dcap["phantomjs.page.settings.userAgent"] = ("Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2227.1 Safari/537.36") 
    dvvr =webdriver.PhantomJS("phantomjs.exe", desired_capabilities=dcap)

However, when I run the code it is sending the default UserAgent of Python-urllib/3.5

Amitesh
  • 113
  • 2
  • 10
  • Possible duplicate: http://stackoverflow.com/questions/29916054/change-user-agent-for-selenium-driver – payne Mar 04 '17 at 15:25
  • No It is not a duplicate. It is the same code that is not working on the latest version of PhantomJS. It shows the correct value when we print desired capabilities variable... but it is passed incorrectly in the headers of sent requests. Nothing seems to be working. – Amitesh Mar 05 '17 at 05:42
  • did you find a solution? also how did you check the header of sent request? – J. Does Dec 21 '17 at 16:13
  • How do you know: "it is sending the default UserAgent of Python-urllib/3.5"? – NegaOverflow Jul 24 '19 at 21:59

0 Answers0