Reputation: 35
I want to log in that website, but can't add my credentials.
The first part of my code is:
from selenium import webdriver
PATH = 'C:\\Program Files (x86)\\Google\\Chrome\\Application\\chromedriver.exe'
driver = webdriver.Chrome(PATH)
driver.maximize_window()
driver.get('https://glovoapp.com/ro/buc/store/kaufland-buc/')
login = driver.find_element_by_xpath('//*[@id="user-login"]')
login.click()
After that, tried using find_element_by_xpath()
and a few other methods, but none of them worked, as it either says "Unable to locate element" or "element not interactable". How can I do it? In previous examples I have followed I could find it with find_view_by_id()
but now I encounter some problems.
Upvotes: 0
Views: 131
Reputation: 193108
To log in that website you need to induce WebDriverWait for the element_to_be_clickable()
and you can use either of the following Locator Strategies:
Using CSS_SELECTOR
:
driver.get("https://glovoapp.com/ro/buc/store/kaufland-buc/")
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "button#user-login"))).click()
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "div#login-email div input"))).send_keys("[email protected]")
Using XPATH
:
driver.get("https://glovoapp.com/ro/buc/store/kaufland-buc/")
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//button[@id='user-login']"))).click()
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//div[@id='login-email']//following::input[@data-test-id='text-field-input']"))).send_keys("[email protected]")
Note: You have to add the following imports :
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
Browser Snapshot:
Upvotes: 1