Selecting page number from dropdown using Selenium python

Question:

I am attempting to change the page number to page 2 from the default of page 1 on https://stats.oecd.org/Index.aspx?DataSetCode=REVDEU

Currently my code opens the page, and seemingly does nothing, eventually timing out.

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

driver = webdriver.Chrome()
driver.get("https://stats.oecd.org/Index.aspx?DataSetCode=REVDEU")


select = Select(WebDriverWait(driver, 20).until(EC.element_to_be_clickable(
    (By.XPATH, "//select[starts-with(@id, 'PAGE')][starts-with(@name,'PAGE')]"))))
select.select_by_visible_text('2')
Asked By: user888469

||

Answers:

You are useing the Select not correctly.
This worked for me:

from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.support.select import Select
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC

options = Options()
options.add_argument("start-maximized")

webdriver_service = Service('C:webdriverschromedriver.exe')
driver = webdriver.Chrome(options=options, service=webdriver_service)
wait = WebDriverWait(driver, 5)

url = "https://stats.oecd.org/Index.aspx?DataSetCode=REVDEU"
driver.get(url)

select = Select(driver.find_element(By.ID, 'PAGE'))
select.select_by_value('2')

The result is

enter image description here

Answered By: Prophet