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:

Leave a comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.