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?
The user Agent header has a particular string that provides the network protocol along with the details of operating system, software version, application, and so on. Selenium does have the ability to get or modify user Agent. This is done with the help of the JavaScript Executor.
Conclusion – Selenium User-Agent In user agent is the important one and it is the way for interacting with the web servers to determine how we are accessing the browsers that can be used on the performance. Generally, it acts as String, boolean, Number are the types to create the user preference type.
Navigate to Team => Commit. #7) Right-click on the Selenium automation project and navigate to Team => Add to Index. #8) Enter the commit message and click on the Commit button. This will add all your Test Cases files to staged changes.
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!
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