Extract the value of a WebElement

Often, we obtain an object from a Web page or a mobile application that contains a value we wish to extract. For this purpose, use the WebElement getText() method, as demonstrated in the following example: 

Copy
WebElement element = driver.findElementByXPath("//android.widget.TextView[../@content-desc='Driving mode']"); //Modify the xpath according to your wishes
// To obtain the driving time value from the found element:
String drivingTime = element.getText();