24

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
  • 6,237
  • 5
  • 26
  • 40
bkemmer
  • 400
  • 1
  • 2
  • 9

1 Answers1

51

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
  • 6,237
  • 5
  • 26
  • 40