How to click a link with Selenium WebDriver using Python?

How to click a link with Selenium WebDriver using Python?

QA 0

Clicking on a website link with Selenium WebDriver is a two-step process:

1) Locate the link element on the webpage

2) Click on the located link using Selenium’s ‘click’ method

Python Code:

import win32com.client
x = win32com.client.Dispatch("AppRobotic.API")
from selenium import webdriver

# navigate to Yahoo
driver = webdriver.Firefox()
driver.get('https://www.yahoo.com')
# sleep 1 second
x.Wait(1000)

link = driver.find_element_by_link_text('Mail')
link.click()