Try element.getAttribute("value")
The text
property is for text within the tags of an element. For input elements, the displayed text is not wrapped by the <input>
tag, instead it’s inside the value
attribute.
Note: Case matters. If you specify “Value”, you’ll get a ‘null’ value back. This is true for C# at least.
More Related Contents:
- What is the difference between ChromeDriver and WebDriver in selenium?
- Element MyElement is not clickable at point (x, y)… Other element would receive the click
- When to use explicit wait vs implicit wait in Selenium Webdriver?
- How to handle authentication popup with Selenium WebDriver using Java
- How to handle windows file upload using Selenium WebDriver?
- How to gettext() of an element in Selenium Webdriver
- pageLoadTimeout in Selenium not working
- Cannot find firefox binary in PATH. Make sure firefox is installed
- Selenium WebDriver: Wait for complex page with JavaScript to load
- How to ignore protected Mode Settings for Internet Explorer using setCapability() through Selenium and Java?
- Find div element by multiple class names?
- javascript error: Failed to execute ‘elementsFromPoint’ on ‘Document’: The provided double value is non-finite
- Exception in thread “main” java.lang.IllegalStateException: The driver executable does not exist while running Selenium Test on Ubuntu
- File Upload using Selenium WebDriver and Java Robot Class
- Check if element is clickable in Selenium Java
- Selenium WebDriver and DropDown Boxes
- java.lang.IllegalAccessError: tried to access method com.google.common.util.concurrent.SimpleTimeLimiter. when using Selenium-Java 3.5.1 or above
- Selenium InternetExplorerDriver doesn’t get focus on the window
- “OsProcess checkForError : CreateProcess error=193, %1 is not a valid Win32 application” while starting Internet Explorer through Java and Selenium
- How to set default download directory in selenium Chrome Capabilities?
- How to make Selenium wait until an element is present?
- Why do some elements exist but not interactable/displayed?
- How to perform Basic Authentication for FirefoxDriver, ChromeDriver and IEdriver in Selenium WebDriver?
- Selenium Webdriver – Stale element exception when clicking on multiple dropdowns while HTML DOM doesn’t change
- How to open a link in new tab (chrome) using Selenium WebDriver?
- How do I load a javascript file into the DOM using selenium?
- What is the difference between getText() and getAttribute() in Selenium WebDriver?
- How to mouse hover using java through selenium-webdriver and Java
- org.openqa.selenium.UnhandledAlertException: unexpected alert open
- How can I extract the text of HTML5 Constraint validation in https://www.phptravels.net/ website using Selenium and Java? [duplicate]