I am executing the following script in Selenium Remotedriver and getting an error:
self.driver.execute_script("Object.defineProperty(navigator, 'webdriver', {get: () => undefined})")
The idea behind the code is to hide the webdriver parameter
The error is the following:
selenium.common.exceptions.JavascriptException: Message: javascript error: Cannot redefine property: webdriver
(Session info: chrome=89.0.4389.90)
I am using this question as a reference: Selenium webdriver: Modifying navigator.webdriver flag to prevent selenium detection
I am using python, not Java, however this line of code looks like the way I wrote on python