0

I have been struggling with a find_element_by_class_name. I'm trying to sign into a webpage using selenium and chromedriver. To do so I must first locate the sign in button and click on it. Unfortunately when I use either the find_element_by_class_name or find_element_by_xpath method I get the following error message: selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element

I am using selenium version 3.141.0

chrome version 86.0.4240.75

python3

Here is my code:

import os
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait



# Load driver (for Google Chrome)  
chromedriver = "/usr/local/bin/chromedriver"
os.environ["webdriver.chrome.driver"] = chromedriver
driver = webdriver.Chrome(chromedriver)

url = "https://bib.cnrs.fr/#"


driver.get(url)

# Authentification
driver.implicitly_wait(10)
connexion = driver.find_element_by_class_name("login-button.btn.btn-link").click()

I have tried waiting for the page to load as suggested here: selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element : what should i do and selenium.common.exceptions.NoSuchElementException: Message: Unable to locate element:

I have also tried with the xpath method as suggested here: Trouble finding element in Selenium with Python but to no avail.

Despite the class "login-button.btn.btn-linky" being present in the html source code the function just doesn't seem to find it.

Any help would be greatly appreciated.

1 Answers1

0

The problem was that I had 2 versions of chromedriver, the first one corresponding to an earlier version of chrome I had and the second one corresponding to my new chrome version 86.0.4240.75

It seemed selenium was calling on the older version by default. One can check what version of chromedriver is being used in the error message outputted in the terminal.

I uninstalled chromedriver (both versions) and reinstalled the correct one by getting the correct package (the one corresponding to my google-chrome) here: https://chromedriver.chromium.org/downloads