How to click a webpage element only if it is found by Selenium?

How to click a webpage element only if it is found by Selenium?

QA 0

To check whether an element was found on the page prior to trying to click it, we can read its length with the len() method. If it’s greater than 0, we proceed to click it.

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')
if len(link) > 0
link[0].click()