Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
301 views
in Technique[技术] by (71.8m points)

python - Logging into Flipkart

I am using Python with selenium, and trying to login to the flipkart webpage below is my code and also the html tags. I keep getting "element click intercepted" also my xpath returns null for the username column

xpath used for UN: ("//html[body[div[2][div[div[div[div[div[2][div[form[div[2][input[@type ='text']]]]]]]]]]]]")

from selenium import webdriver
chromedriver = 'E:chromedriverchromechromedriver.exe'
driver = webdriver.Chrome(chromedriver)
driver.maximize_window()
driver.get ('https://www.flipkart.com/')
driver.implicitly_wait(30)
element=driver.find_element_by_link_text("Login").click()
driver.implicitly_wait(30)
element=driver.find_element_by_xpath("//input[@type ='password']").send_keys("hello")
driver.close()

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

To simply enter the username and password and enter.

driver.get ('https://www.flipkart.com/')
wait = WebDriverWait(driver, 10)
wait.until(EC.element_to_be_clickable((By.XPATH, "//span[text()='Enter Email/Mobile number']/parent::label/parent::div/input"))).send_keys("hello")
wait.until(EC.element_to_be_clickable((By.XPATH, "//input[@type ='password']"))).send_keys("hello",Keys.ENTER)

Import

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...