Python - Selenium - Click on link

By xngo on June 17, 2019

The Python code below will open openwritings.net and then click on Python link. Python link to click

from selenium import webdriver
from selenium.webdriver.common.keys import Keys
 
driver = webdriver.Chrome()
driver.get("https://openwritings.net")
 
python_link = driver.find_element_by_link_text("Python")  # Find Python link.
python_link.click()

Here is a video showing the code above in action.

Selenium in action clicking on Python link

Reference

  • https://selenium-python.readthedocs.io/locating-elements.html

About the author

Xuan Ngo is the founder of OpenWritings.net. He currently lives in Montreal, Canada. He loves to write about programming and open source subjects.