Get data from input field or from textarea

In certain situations we need to get data from input field or from textarea.

The selenium getText() function is not good to get the data from input filed (<input>) or from textarea (<textarea>).

driver.findElement(By.xpath(TEXTAREA.XPATH)).getText()returns an empty string.

The solution is to use getAttribute(“value”).

driver.findElement(By.xpath(TEXTAREA.XPATH)).getAttribute("value");

Similar Posts from the author: