How to determine xpath for pagination?

我是研究僧i 提交于 2021-01-29 19:01:08

问题


Given below the HTML code of next button (pagination), kindly suggest xpath for pagination

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

回答1:


Try following xpath.

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

OR

//li[@class='pagination-link next-link']/a[@data-aa-name='srp-next-page'] /span[text()='next']



回答2:


wait = WebDriverWait(driver, 10)    
element =wait.until(EC.element_to_be_clickable((By.XPATH, "//*[contains(text(),'Next'")))    
print element.text

Note : please add below imports to your solution

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


来源:https://stackoverflow.com/questions/61231794/how-to-determine-xpath-for-pagination

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!