1

I tried to select an element with selenium but I'm a beginner.

Here is the element that I tried to select :

<button type="submit" class="btn btn-primary btn-block btn-form">
    Connexion
</button>

I tried this lines on my script :

from selenium import webdriver

driver = webdriver.Chrome(executable_path="chromedriver.exe")
driver.get("https://skysand.fr")

connexion_button = driver.find_element_by_class_name("login")
connexion_button.click()

email_input = driver.find_element_by_id("email")
email_input.send_keys("XXXX")

password_input = driver.find_element_by_id("password")
password_input.send_keys("XXXX")

connect_button = driver.find_element_by_class_name("btn-primary btn-block btn-form")
connect_button.click()

But it is not working :(

selenium.common.exceptions.ElementClickInterceptedException: Message: element click intercepted: Element is not clickable at point (513, 955)

Thanks if you can help me ! (sorry for my bad English...)

3
  • Are you running in regular or headless mode? can you share all your code? Commented Jul 31, 2021 at 21:02
  • I don't know :( I edited my question to show you all the code Commented Jul 31, 2021 at 21:09
  • I see. Now it's OK. Please see my answer. Commented Jul 31, 2021 at 21:15

1 Answer 1

1

In order to select element by multiple class names you should use css_selector or XPath. Also, for this element it would better to use this css locator:

button[type='submit']

So try this:

connect_button = driver.find_element_by_css_selectro("button[type='submit']")
connect_button.click()

Also, this your code needs waits. With them it will look like this:

from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

wait = WebDriverWait(driver, 20)

driver = webdriver.Chrome(executable_path="chromedriver.exe")
driver.maximize_window()
driver.get("https://skysand.fr")

wait.until(EC.visibility_of_element_located((By.CSS_SELECTOR, ".login"))).click()

wait.until(EC.visibility_of_element_located((By.CSS_SELECTOR, "#email"))).send_keys("XXXX")

wait.until(EC.visibility_of_element_located((By.CSS_SELECTOR, "#password"))).send_keys("XXXX")

wait.until(EC.visibility_of_element_located((By.CSS_SELECTOR, "button[type='submit']"))).click()
Sign up to request clarification or add additional context in comments.

3 Comments

It's working ! I have just a new error : selenium.common.exceptions.ElementClickInterceptedException: Message: element click intercepted: Element is not clickable at point (513, 923) But I think it's a problem of the site, it's weird because you can click it manually... Anyhow, thanks for your help
See the updated answer. Let me know if now it works correct?
I also added driver.maximize_window() method. This should resolve this problem.

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.