1

I have an HTML element <input id="input-id" type="text" value="initial">.
After loading the page I can get text from this element using, for example, driver.find_element_by_id("input-id").get_attribute("value").

But then I click on this element and change the text inside (to "edited", for example). Nothing in DOM changes, including value of the value attribute
(i.e. driver.find_element_by_id("input-id").get_attribute("value") still returns "initial" and element in DOM looks like <input id="input-id" type="text" value="initial">)

How can I extract value that is now visible in browser (i.e. string "edited")? Do I need to execute some JavaScript or anything?

1 Answer 1

3

That value doesn't change when you input some new text. You could try to do just this:

driver.find_element_by_id("input-id").get_attribute("innerHTML")
Sign up to request clarification or add additional context in comments.

4 Comments

But innerHTML also does not change when I enter text, does it? I mean, nothing appears between <input> and </input>.
@StacyMiller You should test it for you case. However why do you want to get the text that YOU put in the field?
I already tested and nothing appears, that is why I am asking. I need it because it seems more clear from the code style point in my case. However, I may do some code refactoring.
I understand. I'm actually using Selenium for a project of mine, so I will try to understand better what's going on here and in case update the info.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.