【问题标题】:Not able to click on a link. I'm getting the error 'Element is not clickable at point'无法点击链接。我收到错误“元素无法点击”
【发布时间】:2019-03-29 18:55:20
【问题描述】:

无法点击链接。 我看到错误

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)

重要提示代码不适用于 "Санкт-Петербург"

【问题讨论】:

    标签: python selenium selenium-webdriver


    【解决方案1】:

    此页面上有 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
    

    【讨论】:

      猜你喜欢
      • 2017-04-13
      • 2018-05-01
      • 2021-07-02
      • 2019-09-17
      相关资源
      最近更新 更多