Reputation: 13
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...)
Upvotes: 1
Views: 297
Reputation: 33361
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()
Upvotes: 1