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.

5
  • where's the page link? Commented Oct 29, 2020 at 9:38
  • in the variable "url" Commented Oct 29, 2020 at 10:11
  • 1
    Spelling mistake in the button class name. It's link not linky Commented Oct 29, 2020 at 10:35
  • This xpath also works //button[normalize-space()='Sign in'] Commented Oct 29, 2020 at 11:20
  • Thank you for comments. Unfortunately these changes don't make it work for me Commented Oct 29, 2020 at 13:40

1 Answer 1

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.