Explore Courses Blog Tutorials Interview Questions
0 votes
in DevOps and Agile by (19.7k points)

In the HTML of a web app, there is the following code

<input type="text" name="prettyTime" id="prettyTime" class="ui-state-disabled prettyTime"  readonly="readonly">

 What is actually shown on the page is a string displaying the time.

In Selenium Web Driver, I have a WebElement object referring to the <input>  using

WebElement timeStamp = waitForElement("prettyTime"));

I want to get the value of the WebElementor, in other words, what is printed on the page. I tried all the WebElement getters and nothing has been retrieving the actual value that the user sees. Any help? Thanks. 

1 Answer

0 votes
by (62.9k points)

 The following code is what I use in Selenium 2.0:

WebElement element = driver.findElement("input_name")); String elementval = element.getAttribute("value");


String elementval = driver.findElement("input_name")).getAttribute("value");

Hope this was helpful.


Browse Categories