Selenium getText Selenium getText selenium selenium

Selenium getText


http://selenium.googlecode.com/svn/trunk/docs/api/java/org/openqa/selenium/WebElement.html#getText()

getText() delivers the innerText of a WebElement.

Your input field does not have any inner Text. The text is found inside your value-attribute, hence accessing it via getAttribute("value") is the correct way to do it.


Javaele.getAttribute("innerHTML");

This could get the text already in the background and not displayed on the page yet.


Simple answer - it's designed this way. getText() parses the content of the tag (i.e. its innerText), which is obviously empty for inputs.