无法单击链接。 我看到错误了
ElementClickInterceptedException:消息:无法在以下位置单击元素 点(116,32),因为另一个元素遮住了它
我的代码:
URL = "https://lenta.com/goods-actions/weekly-products/"
driver = webdriver.Firefox()
driver.get(URL)
time.sleep(2)
# ans = driver.find_element_by_link_text("Казань") this link works OK
ans = driver.find_element_by_link_text("Санкт-Петербург") # ERROR
ans.click()
time.sleep(5)
print("go next")
driver.get(URL)
重要代码仅对“Санкт-Петербург”
不起作用答案 0 :(得分:2)
此页面上有2个文本字符串,其值为“Санкт-Петербур”。一个在覆盖层中;另一个在覆盖层中。一个在页面标题中。该脚本试图单击标题中的链接(但不能,因为覆盖层具有焦点)。
from selenium import webdriver
URL = "https://lenta.com/goods-actions/weekly-products/"
driver = webdriver.Chrome()
driver.get(URL)
ans = driver.find_element_by_link_text("Санкт-Петербург")
print(ans.get_attribute("class"))
#=> link current-store__link js-pick-city-toggle