Locating strategy by Partial Link Text

Same as previous section, locating strategy by Link Text, Partial Link Text also deals with the Text if the link. But only difference is this can select the element with partially matching with the specified link text. See below code:

driver.findElement(By.partialLinkText(“Partial link text”));

Scenario with Example:

import org.openqa.selenium.By; 
import org.openqa.selenium.WebDriver; 
import org.openqa.selenium.WebElement; 
import org.openqa.selenium.chrome.ChromeDriver;   
public class Locator_By_ID {   
public static void main(String[] args) 
WebDriver driver= new ChromeDriver() ; 
login_button= driver.findElement(By.partialLinkText("Partial link text"));

Leave a Reply

Your email address will not be published. Required fields are marked *