After chrome is upgraded to chrome88, selenium modifies the window navigator. webdriver

Write in front

Google released chrome 88 (big update) in the stable version on January 19, 2021

  • Improved dark themes for Windows 10 and less intrusive permission tips
  • FTP URL, Flash, Mac OS X Yosemite are no longer supported
  • Less intrusive permission requests
  • All legacy browser plug-ins are disabled
  • Digital goods API: Web applications published in Google Play store can now use Play store billing like local applications.
  • WebXR: AR lighting estimation: for AR and VR content on Android, lighting estimation can help make the model feel more natural and make it more "suitable" for the user's environment.
  • Anchor target =_ blank means rel = nopopener by default: in order to defend against "tag eavesdropping" attacks, the anchor of the target is_ blank behaves like rel is set to nopower.
  • CSS aspect ratio attribute: This allows you to explicitly specify the aspect ratio for any element to obtain similar behavior to the replaced element. Source isolation: Web applications can choose to improve page security in exchange for giving up access to some API s.
  • JavaScript engine: Chrome 88 integrates version 8.8 of V8 JavaScript engine.

More updated information can be searched by yourself

What I want to write today is that the update to chrome88 has invalidated the selenium crawler data automatic collection code that has been used for a long time. This is the second time that my code has been invalidated because of the browser update. In line with the principle of recording my work, I have been continuously updating this aspect, so many friends have come to ask me this question, If you don't understand, you can click the link below to go directly to the previous article. For those who can't modify window.navigator.webdriver caused by [chrome88], just read this article directly

1, sycm data automation without success 2, About modifying window navigator. Webdriver code failure 3, (New) about modifying window navigator. Webdriver code failure

Problem finding

Version information

The main reason why the code cannot be used is the same as before:

  • window.navigator.webdriver value is true

After several days of investigation, the main reason is

Chrome 88 integrates version 8.8 of the V8 JavaScript engine, which invalidates the original js code that modifies attributes

# Originally modified window navigator. js code block of webdriver
 Object.defineProperty(navigator, 'webdriver', {
          get: () => undefined

Unable to redefine the properties of webdriver using the defineproperty function


I'm not very familiar with js. I planned to use the new js writing method for window navigator. Webdriver was redefined. After several days of efforts, it failed. Other partners can try this direction. There are good ways to communicate in the comment area

Final solution: Start with selenium and use the -- Disable blink features = automationcontrolled parameter to remove the window navigator. webdriver

#Manual login
def login(extension_path,tmp_path):
    chrome_options = webdriver.ChromeOptions()
    # Set up the application extension
     #Add download path
    prefs = {'profile.default_content_settings.popups': 0, 'download.default_directory':tmp_path,
             "profile.default_content_setting_values.automatic_downloads":1}#Allow multiple file downloads
    chrome_options.add_experimental_option('prefs', prefs)

    #Modify windows navigator. Webdriver, anti robot recognition mechanism, selenium automatic login discrimination mechanism
    chrome_options.add_experimental_option('excludeSwitches', ['enable-automation']) 
#     drive = webdriver.Chrome(chrome_options=chrome_options)
    drive = webdriver.Chrome(options=chrome_options)
    url = ''
    input("Please log in manually and enter [1] after success:")
    #Cross out the irrelevant elements of the page and then enter 1 to continue
    drive.maximize_window() #window maximizing
    return drive

Successful test, perfect modification, successful login!

Added by buildakicker on Fri, 07 Jan 2022 03:18:49 +0200