ElementClickInterceptedException:消息:元素在(x,y)点不可点击,因为另一个元素将其遮盖了

时间:2019-10-06 08:10:05

标签: python selenium

嗨,我继续收到错误ElementClickInterceptedException:消息:元素在(x,y)点不可点击,因为另一个元素将其遮盖了

我尝试了许多解决方法,包括延时,但似乎没有任何效果。我在这里尝试了一些解决方案:Selenium Web Driver & Java. Element is not clickable at point (x, y). Other element would receive the click

然后我收到一个新错误,“无法向下滚动”

感谢任何帮助。这是我的代码:

from selenium import webdriver
import time

    browser = webdriver.Firefox()
    browser.get('https://keepa.com/#!')
    browser.implicitly_wait(2)
#login to site
    isbn = browser.find_element_by_id('panelUserRegisterLogin').click()
    isbn = browser.find_element_by_id('username')
    isbn.send_keys('xxxx')
    isbn = browser.find_element_by_id('password')
    isbn.send_keys('xxxx')
    isbn = browser.find_element_by_id('submitLogin').click()
  #open search bar and lookup asin

    isbn = browser.find_element_by_id('menuSearch').click()
    isbn = browser.find_element_by_id('searchInput')
    isbn.send_keys(xxxx)
    isbn.submit()

1 个答案:

答案 0 :(得分:1)

正如我之前提到的,它是Element is not clickable at point (x, y)的副本,您可以在其中找到错误的详细原因和解释。
这是正确的代码:

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

browser = webdriver.Chrome()
wait = WebDriverWait(browser, 5)

browser.get("https://keepa.com/#!")

#login to site
wait.until(ec.element_to_be_clickable((By.ID, "panelUserRegisterLogin"))).click()
browser.find_element_by_id("username").send_keys("xxxx")
browser.find_element_by_id("password").send_keys("xxxx")
browser.find_element_by_id("submitLogin").click()

#open search bar and lookup asin
wait.until(ec.invisibility_of_element_located((By.ID, "loginOverlay")))
wait.until(ec.element_to_be_clickable((By.ID, "showSearchBar"))).click()

search_input = wait.until(ec.element_to_be_clickable((By.ID, "searchInput")))
search_input.send_keys("xxxx")
search_input.submit()