How to get typed text from a textbox by using Selenium Webdriver

+1 vote
How to get typed text from a textbox by using Selenium Webdriver?
Jun 25, 2019 in Selenium by Ashmita
42,876 views

4 answers to this question.

+2 votes
Best answer

Hey Ashmita, to get the typed text from a textbox, you can use getAttribute(“value”) method by passing arg as value. Value attribute stores the typed text of the textbox element. See the following example to know better: 

String typedText = driver.findElement(By.xpath("xpath_textbox")).getAttribute("value"));
answered Jun 25, 2019 by Abha
• 28,140 points

selected Dec 31, 2019 by Kalgi
thanks for your valueable info and keep on doing like this ..it is really usefull
Hello, can you please upvote the answer if it has helped you?

Thanks :)
Thanks a lot!
I want get the frequently changing text in console using java selenium......like while booking tickets the order id will be change ....i want to print the order id....how to?
+1 vote

var val = driver.findElement(webdriver.By.name("AccToken")).getText();
javascript:
  1. String text = (String) jsExecutor.executeScript("return document.getElementById('txtfirstName').value");  

 

answered Sep 6, 2020 by Sri
• 3,190 points