Skip to content
Advertisement

Selenium – couldn’t click next page

I’m trying to click the next button (>) and then repeat until the last page is reached. I’ve tried searching for solutions from similar questions but I couldn’t figure out what’s wrong/make it work.

Here is my code, thank you!

JavaScript

Advertisement

Answer

Your xpath looks incorrect, please try the below

Xpath

JavaScript

CSS Selector

JavaScript

There are multiple approaches to address this issue and a couple of them are as follows:

As you intent to invoke click() you need to induce WebDriverWait in conjunction with the WebDriverWaitWebDriverWait for the element_to_be_clickable() and you can use either of the following Locator Strategies:

Using CSS_SELECTOR:

JavaScript

Using XPATH:

JavaScript

Incase the error …another element obscures it… still persists first you need to induce WebDriverWait inconjunction with the expected_conditions for the invisibility_of_element() of the blocking element as follows:

Using CSS_SELECTOR:

JavaScript

Using XPATH:

JavaScript

If the issue still persists you can use the execute_script() method as follows:

Using CSS_SELECTOR:

JavaScript

Using XPATH:

JavaScript

Note: : You have to import below

JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement