Selenium itself doesn't contain any click but contains a method which you can invoke to simulate a click on a clickable element.
The click()
mehtod is defined as:
def click(self):
"""Clicks the element."""
self._execute(Command.CLICK_ELEMENT)
You can invoke the click()
mehtod on any clickable element as many as possible times you can.
Ideally, to click on the element you need to induce WebDriverWait for the element_to_be_clickable()
and you can use either of the following Locator Strategies:
Using LINK_TEXT
:
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.LINK_TEXT, "Click Link"))).click()
Using PARTIAL_LINK_TEXT
:
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.PARTIAL_LINK_TEXT, "Click Partial Link"))).click()
Note: You have to add the following imports :
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC