Reputation: 15
I want to login in aliexpress by using selenium. But i can't find element xpath of input email to sendkeys. I try so many times by css_selector, xpath, But it's not work.
This is my code:
driver.get("https://best.aliexpress.com")
time.sleep(5)
userinfo= driver.find_element(By.CSS_SELECTOR,"div.my-account--menuItem--1GDZChA")
userinfo.click()
login_button=driver.find_element(By.CSS_SELECTOR,"span.my-account--menuText--1km-qni")
login_button.click()
driver.find_element(By.CSS_SELECTOR,"span.cosmos-input-label").send_keys("test")
I want to send the email in right input email label
Upvotes: 0
Views: 360
Reputation: 4804
You have this issue, because you rely on wrong element.
First, you should rely on input element and not on input label.
Second - sign in containers for different screen resolutions have different classes. cosmos-input
class is not present for not maximized window, it's class is comet-input
.
Unique attribute that is present in both cases is [label=Email]
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
driver = webdriver.Chrome()
driver.get("https://best.aliexpress.com")
wait = WebDriverWait(driver, 10)
userinfo = wait.until(EC.presence_of_element_located((By.CSS_SELECTOR, 'div.my-account--menuItem--1GDZChA')))
userinfo.click()
login_button=driver.find_element(By.CSS_SELECTOR,"span.my-account--menuText--1km-qni")
login_button.click()
login = wait.until(EC.presence_of_element_located((By.CSS_SELECTOR, '[label=Email]')))
login.send_keys("test")
Upvotes: 0
Reputation: 271
here is you're path //input[@class='cosmos-input']
you can use this to input you're email make sure first click on the signin button properly then the popup screen will be open and with the help of this xpath //input[@class='cosmos-input']
you can use send_keys for inserting the email
Upvotes: 0