Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

clicking a button in selenium python

# 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()
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #clicking #button #selenium #python
ADD COMMENT
Topic
Name
6+5 =