Next Page not opening using Selenium

<li class="item pages-item-next">
<a class="action  next" href="https://oup.com.pk/academic-generalbooks.html?p=2" title="Next">
 <span class="label">Page</span>
  <span>Next</span>
 </a>
 </li>

Above is the code of HTML, i’m trying to click next page using selenium in python, but it is not clicking. my code is down here:

x=browser.find_element(By.CLASS_NAME,’action.next’)

x.click()

why i’m getting this error:
ElementNotInteractableException

Any help would be appreciated.

>Solution :

Root cause:

By.CLASS_NAME,'action.next' – This is incorrect.

By.CSS_SELECTOR, '.action.next' This is correct

Try this using XPATH locator:

x = WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//a[contains(@class,'action  next')]")))
x.click()

Imports:

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

Leave a Reply