How to Click a Button on a Webpage Using Selenium | How To Click a Link on a Webpage Using Python



from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import time

#-----------------Firefox------------------------
driver = webdriver.Firefox()
driver.get("https://pythonwitheasyway.blogspot.com/")
print(driver.title)
print(driver.current_url)

#X_PATH of the link is given inside the quotation

driver.find_element_by_xpath("/html/body/div[3]/div[6]/div[5]/div[1]/
div[4]/div[2]/div[1]/div[1]/div/div[3]/article/div[3]/a").click()
#It'll stay on that page for 10 seconds
time.sleep(10)
driver.close() # Close only current window
#driver.quit() # It'll close the entire browser.

Comments