Selenium登录过程自动执行到Grofers-Python

时间:2020-07-02 16:01:42

标签: python selenium selenium-webdriver automation

我正在尝试使登录Grofers(印度电子商务杂货市场)的过程自动化。 我的代码是:

from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import time

driver = webdriver.Firefox()
time.sleep(1)

driver.get('https://grofers.com/')
time.sleep(3)

login = driver.find_element_by_class_name('account-wrapper')
login.click()
time.sleep(3)

mobileNo = driver.find_element_by_xpath('//*[@id="phone-no-text-box"]')
mobileNo.send_keys('<Phone Number>')
time.sleep(3)

cont = driver.find_element_by_xpath('//*[@id="login-next-button"]')
cont.click()

运行此脚本时,出现以下错误:

elenium.common.exceptions.ElementClickInterceptedException: Message: Element <div class="account-wrapper"> 
is not clickable at point (1136,57) because another element <div class="location__overlay"> obscures it

无法超越。有人可以帮忙吗?

编辑:我解决了这个问题。如果有人遇到相同的问题,他们可以让我知道,我将分享我的代码段。

1 个答案:

答案 0 :(得分:0)

页面上的位置选择器要求您选择一个关闭位置。

第一次添加此代码。sleep(3)应该可以解决问题,它只是找到并选择默认位置Gurugram。

locationSelecter = driver.find_element_by_xpath("/html/body/div[1]/div/div[2]/div[2]/header/div[2]/div[2]/div/div/div/div[1]/div[2]")
locationSelecter.click()
time.sleep(10)