How I can navigate page a page clicking next button?

I want to navigate into a web with a lof of pages, and I try to click next button to pass to the next page. The web is: https://www.truity.com/search-careers My code is:

from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.select import Select
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
import time

path = 'C:/Users/.../chromedriver'
driver = webdriver.Chrome(path)
driver.get("https://www.truity.com/search-careers")

while True:
    elements = driver.find_elements_by_xpath('//*[@id="block-system-main"]/div/div[3]/div/table/tbody//a')

    links = []
    for i in range(len(elements)):
        links.append(elements[i].get_attribute('href'))

    for link in links:
        print('navigating to: ' + link)
        driver.get(link)
        # Title
        title.append(driver.title)
        #....

        driver.back()
        
    try:
        driver.find_element_by_xpath('//*[@id="block-system-main"]/div/div[4]/ul/li[11]/a').click()
    except NoSuchElementException:
        break

But my code is not correct. Can you help me? Thanks!



Read more here: https://stackoverflow.com/questions/66329700/how-i-can-navigate-page-a-page-clicking-next-button

Content Attribution

This content was originally published by Sonia Aparicio at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: