How can we fetch a text written over an element?

How can we fetch a text written over an element?

Hi Dipen Soni,

Using the getText() method we can fetch the text over an element.

String text = driver.findElement("elementLocator").getText();