python - Selenium 按钮不可点击的 Python
问题描述
我正在尝试单击此站点上的下一页按钮。我在 Stack Overflow 上查看了多个针对类似问题提出的解决方案,但它们似乎都不起作用。这是我目前的代码:
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
wait = WebDriverWait(driver, 10)
next_button = wait.until(EC.element_to_be_clickable((By.XPATH, "html/body/div/div/div/main/div[3]/div[2]/div/div[3]/div[1]/div[2]/div[2]/div/div[1]/div[3]/button[2]/i/svg")))
driver.execute_script("return arguments[0].scrollIntoView();", next_button)
next_button.click()
任何帮助,将不胜感激。谢谢!
解决方案
您可以尝试如下:
wait = WebDriverWait(driver, 10)
next_button = wait.until(EC.element_to_be_clickable((By.XPATH, '(//*[@class="anticon anticon-right"])[2]')))
driver.execute_script("return arguments[0].scrollIntoView();", next_button)
next_button.click()
推荐阅读
- laravel - 每个租户的多租户和自定义功能
- sql - 仅显示 MAX 行
- algorithm - 图中所有可能的路径
- arrays - 如何在执行快速排序时正确找到枢轴元素?
- javascript - 数字计数器将数字从 1 增加到最大值,然后从该值减少到 1。但它应该增加然后停止
- c# - C# 将 bool 重新解释为 byte/int(无分支)
- android - 无法使用 react-native start 捆绑应用程序
- c++ - 检测到子进程因操作系统内存不足而被杀死
- python - 遍历目录并从找到的 .py 文件中获取函数名称
- javascript - 在我登录时从自定义管理网站在 Firebase Auth 中创建帐户