Identifying the WebElement by “PARTIAL_LINK_TEXT” locator.It takes String as an argument. If an element isn't identified it throws an exception as NoSuchElementException.
Here we will not enter the complete string of a link text.For an example if we have a link text as “FORM” we can enter a partial text of this as “FO” or “FOR” etc. But this partial text which is entered should be a unique then we can act on that particular webelement.
Syntax: driver.find_element(By.PARTIAL_LINK_TEXT,"FORM")
Example: In the below example we will launch the webpage and click on the Form link to redirect to another page.
Partial_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.PARTIAL_LINK_TEXT,"FOR")
ele.click()
# OR
driver.find_element(By.PARTIAL_LINK_TEXT,"FOR").click()
time.sleep(5)
driver.quit()