Selenium WebDriver for retrieving HTML input value

0 votes

Following code is the HTML of a page. 

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

The display on the page is simply a string displaying time.
In WebDriver, there is a WebElement object referring to <input> tag using

WebElement timeStamp = waitForElement(By.id("prettyTime"));

I want the value of the element (what ever is displayed on the page). I tried every WebElement getters and nothing is useful for retrieving the value that the user sees. Any help? Thanks.

May 23, 2018 in Selenium by abc_xyz
600 views

1 answer to this question.

0 votes

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.

answered May 23, 2018 by sniffy_god
• 780 points

Related Questions In Selenium

0 votes
1 answer

Selecting a dropdown value in Selenium WebDriver

Try to wrap your WebElement as shown ...READ MORE

answered Apr 9, 2018 in Selenium by QueenBee
• 1,820 points
1,569 views
0 votes
1 answer

Locating an element by value using css selector using Selenium WebDriver

Below code will help By.cssSelector("td[class='someclass'][value='u ...READ MORE

answered Apr 9, 2018 in Selenium by coldcode
• 2,050 points
273 views
0 votes
1 answer

Using gettext() method for the specific element using Selenium WebDriver

Mistake is that u r printing the ...READ MORE

answered Apr 10, 2018 in Selenium by Vardy
• 2,370 points
13,347 views
0 votes
1 answer

Finding WebDriver element with Class Name in java

The better way to handle this element ...READ MORE

answered Apr 10, 2018 in Selenium by nsv999
• 5,510 points
2,215 views
0 votes
1 answer
0 votes
1 answer

Geo-location microphone camera pop up

To Allow or Block the notification, access using Selenium and you have to ...READ MORE

answered May 11, 2018 in Selenium by Samarpit
• 5,870 points
1,823 views
0 votes
1 answer

How to use such xpath to find web elements

It's much simpler to use: #MyDiv123 > div.super or ...READ MORE

answered Jun 14, 2018 in Selenium by Samarpit
• 5,870 points
1,818 views
0 votes
2 answers

When executing my Jenkins tests with Selenium WebDriver, I do not see a GUI.

Hi eLiJha, I also faced the same issue ...READ MORE

answered Jul 15, 2019 in Selenium by nayan
• 160 points
2,796 views
+1 vote
2 answers

Is it possible to scroll down in a webpage using selenium webdriver programmed on python?

I using next code for facebook for ...READ MORE

answered May 16, 2019 in Selenium by mslavikas@gmail.com
13,394 views