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:
- How to select an element from table if there is no ID
- Reading test data from a CSV file using JUnit
- Creating a data-driven test with JUnit
- Parameterized JUnit tests with Selenium WebDriver
- How to count number of images available on a web page then download them using selenium webdriver?
Recent Comments