如何确定用于分页的xpath



下面给出了下一个按钮(分页(的HTML代码,建议使用xpath进行分页

<li class = "pagination-link next-link">
<a data-aa-region="srp-pagination" data-aa-name="srp-next-page"
<span>next</span>
</a>

尝试以下xpath

//li[@class='pagination-link next-link']/a[./span[text()='next']]

//li[@class='pagination-link next-link']/a[@data-aa-name='srp-next-page'] /span[text()='next']
wait = WebDriverWait(driver, 10)    
element =wait.until(EC.element_to_be_clickable((By.XPATH, "//*[contains(text(),'Next'")))    
print element.text

注意:请将以下导入添加到您的解决方案中

from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait

最新更新