问题
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