【发布时间】:2021-12-09 21:47:07
【问题描述】:
我是 selenium 的新手,我尝试在页面上导航并单击按钮以使用 selenium Web 驱动程序进入下一页。
这是我的python代码:
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
WebDriverWait(driver, 30).until(EC.presence_of_element_located((By.XPATH, '//*[@id="page"]/div/div/div[5]/div/div/div/div[3]/div/span[2]')))
driver.find_element(By.XPATH, '//*[@id="page"]/div/div/div[5]/div/div/div/div[3]/div/span[2]').send_keys(Keys.RETURN)
print('Element found')
除了send_keys(Keys.RETURN),我还试过send_keys(Keys.ENTER)和click()。在所有情况下,“找到元素”语句都会打印到控制台,但网页上没有任何反应。
这是按钮的 HTML 位:
<span class="ACME-src-ACME-ui-Pagination--arrowRight">
<i class="flaticon-right-arrow"></I>
</span>
我们非常感谢每一个帮助。
【问题讨论】:
-
你试过用Javascript点击吗?
标签: python html selenium xpath