【问题标题】:Python 3.7 Help on Selenium-Element could not be scrolled into view无法滚动查看有关 Selenium-Element 的 Python 3.7 帮助
【发布时间】:2022-08-18 21:51:20
【问题描述】:

我收到此错误:

\“selenium.common.exceptions.ElementNotInteractableException:消息:元素无法滚动到视图中\”

这是我正在使用的代码:

driver.find_element_by_xpath(\'//*[@class=\"next\"]\').click()

这是来自检查员:

你能告诉我如何点击“下一步”吗?

非常感谢。

    标签: python selenium selenium-webdriver python-3.7


    【解决方案1】:

    当您使用 Selenium 打开该页面时,该元素似乎位于最初可见的屏幕之外。
    尝试将其滚动到视图中,然后使用以下代码单击它:

    from selenium.webdriver.common.action_chains import ActionChains
    
    actions = ActionChains(driver)
    
    pager = driver.find_element_by_xpath('//li[@class="next"]')
    actions.move_to_element(pager).perform()
    time.sleep(0.5)
    pager.click()
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-11-23
      • 1970-01-01
      • 2016-05-19
      • 2011-03-26
      • 2021-07-23
      相关资源
      最近更新 更多