I have the right username and passwd, but failed login with selenium(Python)+Chromedriver

Viewed 37

'window.navigator.webdriver' had set to 'undefined', but I still can't log in. Do you have any solutions? Selenium has been blocked by many websites. Maybe I should change a tool. But I still hope someone can help me to figure out what's wrong with this website. Thank you.

Here's my code:

# -*- coding: utf-8 -*-

from selenium import webdriver


options = webdriver.ChromeOptions()
options.add_experimental_option('excludeSwitches', ['enable-automation'])
browser = webdriver.Chrome(chrome_options=options)
browser.execute_cdp_cmd("Page.addScriptToEvaluateOnNewDocument", {
  "source": """
    Object.defineProperty(navigator, 'webdriver', {
      get: () => undefined
    })
  """
})

browser.get("https://qdnglpt.gzzhjyy.cn/login.html")

username = 'username'
password = 'password'

browser.find_element_by_id('username').send_keys(username)
browser.find_element_by_id('password').send_keys(password)

loginRandCode = input("Please input Vcode: ")

browser.find_element_by_id('loginRandCode').send_keys(loginRandCode)
browser.find_element_by_xpath('/html/body/div[2]/div/div[2]/div/button').click()
browser.find_element_by_class_name('mr-10').click()

browser.quit()

0 Answers
Related