url = "https://yahoo.com"
driver = Firefox(executable_path="geckodriver.exe")
driver.get(url)
driver.find_element_by_css_selector("button.btn:nth-child(5)").click()
# Finding and clicking elements using XPATH example
from selenium import webdriver
from selenium.webdriver.common.by import By
import time
driver = webdriver.Chrome("C:/chromeDriver/chromedriver") # Make sure you have YOUR path to the chromedriver
driver.get("https://www.youtube.com/")
time.sleep(2)
# Clicking the menu button
driver.find_element(By.XPATH, "/html/body/ytd-app/div[1]/div/ytd-masthead/div[3]/div[1]/yt-icon-button[2]").click()
time.sleep(1)
# Clicking the 'Subscription' link
driver.find_element(By.XPATH, "/html/body/ytd-app/div[1]/tp-yt-app-drawer/div[2]/div/div[2]/div[2]/ytd-guide-renderer"
"/div[1]/ytd-guide-section-renderer[1]/div/ytd-guide-entry-renderer[4]/a").click()
element.click()
from selenium.webdriver import ActionChains
ActionChains(browser).click(element).perform()