简体   繁体   中英

Not able to click on a link. I'm getting the error 'Element is not clickable at point'

Can't click link. I see error

ElementClickInterceptedException: Message: Element is not clickable at point (116,32) because another element obscures it

My code:


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)

code doesn't work only for 代码仅对不起作用

There are 2 text strings with a value of "Санкт-Петербур" on this page. One is in the overlay; one is in the page header. The script is trying to click the link in the header (but can't because the overlay has focus).

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM