python click buttons on websites

from selenium import webdriver
import webbrowser

driver = webdriver.Chrome()
driver.get("example.com")
button = driver.find_element_by_id('idofbutton')
button.click()

Here is what the above code is Doing:
1. Open a Chrome browser
2. Navigate to example.com
3. Find the element with the id ‘idofbutton’
4. Click the button