'How do I get text from input text box in selenium?

I need to insert with selenium to text box and then get it to another use.

enter image description here

how can I do this? The function getText() doesn't work.



Solution 1:[1]

You may try to get the data from attribute value.

driver.findElement(By.id("text-box")).getAttribute("value");

If the above does not work then I believe the JavascriptExecutor will definitely help you to achieve the same.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 UnknownBeast