July 2019
Intermediate to advanced
536 pages
12h 57m
English
The By.partialLinkText locating mechanism is an extension of the By.linkText locator. If you are not sure of the entire link text or want to use only part of the link text, you can use this locator to identify the link element. So, let's modify the previous example to use only partial text on the link; in this case, we will use Privacy from the Privacy Policy link in the site footer:

The code would look like this:
@Testpublic void byPartialLinkTextLocatorExample() { WebElement orderAndReturns = driver.findElement(By.partialLinkText("PRIVACY")); orderAndReturns.click(); assertThat(driver.getTitle()) .isEqualTo( ...
Read now
Unlock full access