Selenium can automatically click on buttons that appear on a webpage. This article revolves around how to click any button using Selenium in a webpage. In order to do this there are two major steps we have to take :
- Find the button.
- Click on the button.
We can find the button on the web page by using methods like find_element_by_class_name(), find_element_by_name(), find_element_by_id() etc, following which we can click on it by using the click() method.
# finding the button using ID button = driver.find_element_by_id(ID) # clicking on the button button.click()
This will click on the button and a popup will be shown.
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course.
- How to add a custom right-click menu to a webpage ?
- How to get title of a webpage using Selenium in Python?
- Count total number of Links In Webpage Using Selenium In Python
- How to set radio button checked by button click in AngularJS ?
- Interacting with Webpage - Selenium Python
- How To Add Google Translate Button On Your Webpage?
- click() element method - Selenium Python
- click method - Action Chains in Selenium Python
- How to call PHP function on the click of a Button ?
- How to load notification alert on top right corner without click of button in bootstrap ?
- How to create button dynamically with click event in Angular ?
- How to add a pressed effect on button click in CSS?
- PyQt5 – Hide push button on click
- How to create a Ripple Effect on Click the Button ?
- PyQt5 – Change text in Radio Button on click
- How to add input fields dynamically on button click in AngularJS ?
- How to set checkbox checked on button click in AngularJS ?
- Reading selected webpage content using Python Web Scraping
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.
Improved By : SamarthiLahiri