0

enter image description here

As you can see from the picture, the pagination is a bit different. So my idea is to get the position of the current-page and get the link for the a tag.

        current_page= driver.find_element(By.CSS_SELECTOR,"span.current-page")
        driver.find_element(By.TAG_NAME,"a").click()

but I didn't know to use the current_page element to find the a tag after it and click on it. Thanks for your help in advance.

1 Answer 1

3

To get the next element using current page reference you can use the following css selector in one liner or XPATH option.

next_page= driver.find_element(By.CSS_SELECTOR,"span.current-page+a")
print(next_page.get_attribute("href"))
next_page.click()

Or you can use this.

current_page= driver.find_element(By.CSS_SELECTOR,"span.current-page")
current_page.find_element(By.XPATH,"./following::a[1]").click()
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.