Interview Questions

Selenium WebDriver - How to click on a hyper link using linkText?

Selenium WebDriver Interview question and Answers


(Continued from previous question...)

Selenium WebDriver - How to click on a hyper link using linkText?

driver.findElement(By.linkText(“Google”)).click();
The command finds the element using link text and then click on that element and thus the user would be re-directed to the corresponding page.
The above mentioned link can also be accessed by using the following command.
driver.findElement(By.partialLinkText(“Goo”)).click();
The above command find the element based on the substring of the link provided in the parenthesis and thus partialLinkText() finds the web element with the specified substring and then clicks on it.

(Continued on next question...)

Other Interview Questions