Trying to click next button from navigation bar of website "https://uk.trustpilot.com/categories/bars_cafes?subcategories=cafe" using selenium in python.
from selenium.webdriver import Chrome
from webdriver_manager.chrome import ChromeDriverManager
from selenium.webdriver.common.by import By
from bs4 import BeautifulSoup
import time
URL = "https://uk.trustpilot.com/categories/bars_cafes?subcategories=cafe"
driver = Chrome(ChromeDriverManager().install())
class Scraper:
def __init__(self, website):
self.website = website
def get_website(self):
return driver.get(self.website)
def ignore_cookie(self):
try:
ignore_cookies = driver.find_element(by=By.XPATH, value='//*[@id="onetrust-reject-all- handler"]')
ignore_cookies.click()
except AttributeError:
pass
def next_page(self):
driver.find_element(by=By.NAME, value="pagination-button-next").click()
The ignore cookie function works fine. But next_page function scrolls to the next button but does not click it.