Identifying the WebElement by “Link Text ” locator.It takes String as an argument. If element doesn’t identified it throws an exception as NoSuchElementException.
Syntax: driver.find_element(By.LINK_TEXT,"FORM")
Example: In the below example we will launch the webpage and click on the Form link to redirect to another page.
LinkText_Locator.py
from selenium import webdriver import time from selenium.webdriver.common.by import By driver = webdriver.Chrome("/Users/admin/Documents/Skill2Lead/Others/drivers/chromedriver.exe") driver.get("http://www.dummypoint.com/seleniumtemplate.html") time.sleep(2) ele = driver.find_element(By.LINK_TEXT,"FORM") ele.click() # OR (We can write the click() operation in same line as below) driver.find_element(By.LINK_TEXT,"FORM").click() time.sleep(5) driver.quit()