I have a text box in the UI from which I want to get the text. The problem is the text is not present in the dom. It is inserted through some javascript/jquery. How to get the text from the text box in such case?

enter image description here

  • 1
    Are you talking about the placeholder or the value attribute. Could you share some more insight. Jul 20, 2018 at 10:10
  • Please add the relevant screenshot of how it looks like in UI.
    – Alexey R.
    Jul 20, 2018 at 10:54
  • I am talking about the value attribute.
    – user33862
    Jul 20, 2018 at 12:25
  • Does a value attribute exist once there is text in the field?
    – Kate Paulk
    Jul 20, 2018 at 13:14

1 Answer 1


What you're trying to access is the value property (current contents of the field) - which is different than the value attribute - See https://stackoverflow.com/questions/6003819/what-is-the-difference-between-properties-and-attributes-in-html. selenium-webdriver used to only provide an attribute method on ::Selenium::WebDriver::Element objects which would return the property if a string property value existed, and otherwise would return the attribute value. Newer versions of selenium-webdriver now also provide a property method on the objects which will return just the property. Assuming you have found the relevant element by some method (id, css, xpath, etc) then in recent versions of selenium-webdriver you should be able to do


In older versions of selenium-webdriver you would do


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.