Categories
Python Answers

How to modify navigator.webdriver flag to prevent selenium detection with Python Selenium?

Spread the love

Sometimes, we want to modify navigator.webdriver flag to prevent selenium detection with Python Selenium.

In this article, we’ll look at how to modify navigator.webdriver flag to prevent selenium detection with Python Selenium.

How to modify navigator.webdriver flag to prevent selenium detection with Python Selenium?

To modify navigator.webdriver flag to prevent selenium detection with Python Selenium, we can call add_experimental_options` to set a few options.

For instance, we write

from selenium import webdriver

options = webdriver.ChromeOptions()
options.add_experimental_option("excludeSwitches", ["enable-automation"])
options.add_experimental_option('useAutomationExtension', False)
driver = webdriver.Chrome(options=options, executable_path=r'C:\path\to\chromedriver.exe')
driver.get("https://www.example.com/")

to call options.add_experimental_option to disable the automation options.

Conclusion

To modify navigator.webdriver flag to prevent selenium detection with Python Selenium, we can call add_experimental_options` to set a few options.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *