anirudha agnihotri
anirudha agnihotri

Reputation: 65

Not able to fetch element from dom using xpath

enter image description here

Not able to fetch element from the dom using xpath

<input bsdatepicker="" class="form-control font-size-normal ng-untouched ng-pristine ng-valid" id="endDate" name="endDate" placement="top" type="text">

The element value is not available in the html code the UI for the above element contains following following value "01/14/2019" but not able to fetch the values.

Even tried to search the element value "01/14/2019" in the entire dom using Ctrl+F but still the value is not saved anywhere in the html dom

Upvotes: 0

Views: 356

Answers (2)

Pratik
Pratik

Reputation: 357

Use element.getAttribute("value") and you will get the value which is visible on the webpage.

Upvotes: 1

Sers
Sers

Reputation: 12255

You want to get value of the input, to do it:

In Chrome console:

document.querySelector("#endDate").value

Selenium Python:

end_date = driver.find_element_by_id("endDate").get_attribute("value")

Selenium Java:

String endDate = driver.findElement(By.id("endDate")).getAttribute("value");

Upvotes: 1

Related Questions