Search code examples
pythonselenium-webdriverweb-scrapingselenium-chromedriver

Selenium couldn't read tbsCertificate as SEQUENCE


I am trying to scrape a website, I need to login to it to continue and when I try to do so I get this error:

[5064:9952:0514/222545.212:ERROR:cert_issuer_source_aia.cc(34)] Error parsing cert retrieved from AIA (as DER):
ERROR: Couldn't read tbsCertificate as SEQUENCE
ERROR: Failed parsing Certificate

Here is my code:

options = webdriver.ChromeOptions()
options.add_argument('--allow-running-insecure-content')

capabilities = {
    'acceptInsecureCerts': True
}

# Set up driver
driver = webdriver.Chrome(options=options, desired_capabilities=capabilities)
driver.get(login_url)

# Locate user login form fields
username_input = driver.find_element(By.CLASS_NAME, 'tst-login-email-input')
password_input = driver.find_element(By.CLASS_NAME, 'tst-login-password-input')

# Fill in the fields
username_input.send_keys(username)
password_input.send_keys(password)

# Click the submit button
submit_button = driver.find_element(By.CLASS_NAME, 'tst-login-submit-button')
submit_button.click()

My browser is up to date. I tried adding arguments to options like: options.add_argument('--allow-running-insecure-content'), options.add_experimental_option('excludeSwitches', ['enable-logging']) and nothing changed.


Solution

  • I think the problem was that I did not wait for something to load. Anyways here is the working code:

    # Set up driver
    driver = webdriver.Chrome()
    driver.get(login_url)
    
    # Login to the site
    username_input = WebDriverWait(driver, 10).until(lambda x: x.find_element(By.CLASS_NAME, 'tst-login-email-input')1)
    username_input.send_keys(username)
    
    password_input = WebDriverWait(driver, 10).until(lambda x: x.find_element(By.CLASS_NAME, 'tst-login-password-input'))
    password_input.send_keys(password)
    
    login = WebDriverWait(driver, 10).until(lambda x: x.find_element(By.CLASS_NAME, 'tst-login-submit-button'))
    login.click()