18

I am trying to get the actual user agent that I am using in Selenium, at the moment with the chromedriver.

I found a Java version of this problem: How to get userAgent information in Selenium Web driver.

Does someone know how to do that in Python?

Ratmir Asanov
  • 5,889
  • 5
  • 24
  • 38
bkemmer
  • 340
  • 1
  • 2
  • 9

1 Answers1

42

The same manner as inside your link:

user_agent = driver.execute_script("return navigator.userAgent;")

PS: Using execute_script method you can run JS inside your driver.

Hope it helps you!

Ratmir Asanov
  • 5,889
  • 5
  • 24
  • 38