I am trying to click on next page button with selenium but I am unable to. The next page does not load and the webpage shows an error, but in the URL box I can see that it clicked because the URL changes.
My code for trying to click on next page is like this:
WebDriverWait(driver, 10).until(
EC.presence_of_element_located((By.CSS_SELECTOR, '[class="page_charts_section_charts_item object_song"]'))
)
next = True
while next == True:
songs = driver.find_elements(By.CSS_SELECTOR, '[class="page_charts_section_charts_item object_song"]')
for song in songs:
song_artist = song.find_elements(By.CSS_SELECTOR, '[class="ui_name_locale_original"]')
genre = song.find_element(By.CSS_SELECTOR, '[class="genre comma_separated first"]')
rating = song.find_element(By.CSS_SELECTOR, '[class="page_charts_section_charts_item_details_average_num"]')
song_list.append(song_artist[0].text)
artist_list.append(song_artist[1].text)
genre_list.append(genre.text)
rating_list.append(rating.text)
try:
WebDriverWait(driver, 30).until(
EC.element_to_be_clickable((By.CSS_SELECTOR, '[class="ui_pagination_next_label"]'))
)
driver.find_element(By.CSS_SELECTOR, '[class="ui_pagination_next_label"]').click()
except:
next = False
And the webpage is this one:
https://rateyourmusic.com/charts/top/song/all-time/a:system%2dof%2da%2ddown/
On the normal browser I can click without any problem, but it seems that the selenium browser works different.
Any suggestion?