Software Development and QA Tips By QASource Experts

How Do You Click Using Selenium Python?

Written by Timothy Joseph | Jul 4, 2022 4:00:00 PM

Based on the current scenario in automation, an open-source tool known as Selenium is widely used by the companies providing QA solutions.

Below is the code snippet to click an element in Selenium using Python:

#import “webdriver” from selenium
#load chrome driver from the path where driver is installed
driver = webdriver.Chrome(executable_path='******\chromedriver.exe')
#maximize the browser
driver.maximize_window()
#navigate to url
driver.get(“https://www.example.com/”)
#create locator for "Free Download" button
loadButton = driver.find_element_by_css_selector("a.btn.btn-success.btn-xl")
#click the button
loadButton.click()