Eva Deltor
Eva Deltor

Reputation: 41

I need to acces to the next page with selenium or Beautiful Soup

I think I have already tried all the .click() .submit... all different kind of things but it doesn't do anything

What appears when I try to acces to the next page is the following, as as isn't a button or appears a web site I don't know what to do; the only thing that changes in all the pages is the number in the value, that here appears a 3

<ul class="pagination">
     <li><span onclick="document.lisarq.pagina.value=3; document.lisarq.submit(); " onmouseover="this.style.cursor='pointer'" style="cursor: pointer;">3</span></li>
</ul>

The only thing that I want to do is access to the next page in this case would be the 4 Thanks!

Upvotes: 1

Views: 112

Answers (1)

undetected Selenium
undetected Selenium

Reputation: 193228

As the element is JavaScript enabled element, to click() and access Page 4 you have to induce WebDriverWait for the element_to_be_clickable() and you can use either of the following solutions:

  • Using CSS_SELECTOR:

    WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "ul.pagination>li>span[onclick*='4']"))).click()
    
  • Using XPATH:

    WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//ul[@class='pagination']/li/span[contains(@onclick, '4') and text()='4']"))).click()
    
  • Note : You have to add the following imports :

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

Upvotes: 1

Related Questions