Complete the code to find a link by its exact visible text.
WebElement link = driver.findElement(By.[1]("Home"));
The findElement(By.linkText()) method locates a link by its exact visible text.
Complete the code to click a link with the exact text "Contact Us".
driver.findElement(By.[1]("Contact Us")).click();
To click a link by its exact text, use By.linkText().
Fix the error in the code to find a link with text "About".
WebElement aboutLink = driver.findElement(By.[1]("About"));
The correct method to find a link by exact text is linkText. Using partialLinkText finds by partial text, which may cause errors if exact match is needed.
Fill both blanks to find and click a link with text "Services".
WebElement serviceLink = driver.findElement(By.[1]("Services")); serviceLink.[2]();
Use By.linkText to find the link by exact text, then call click() to click it.
Fill all three blanks to find a link with text "Login", check if it is displayed, and then click it.
WebElement loginLink = driver.findElement(By.[1]("Login")); if (loginLink.[2]()) { loginLink.[3](); }
Use linkText to find the link by exact text, isDisplayed() to check if it is visible, and click() to click it.