Interview Questions

Selenium WebDriver - How can we get a text of a web element?

Selenium WebDriver Interview question and Answers


(Continued from previous question...)

Selenium WebDriver - How can we get a text of a web element?

Get command is used to retrieve the inner text of the specified web element. The command doesn’t require any parameter but returns a string value. It is also one of the extensively used commands for verification of messages, labels, errors etc displayed on the web pages.
Syntax:
String Text = driver.findElement(By.id(“Text”)).getText();

(Continued on next question...)

Other Interview Questions