Getting value from text input field

Asked by Jason Dunckley on 2013-01-16

Firstly, thanks for publishing this framework, it has a great amount of boilerplate functionality (like reporting/shared library) that is needed for a good test framework, and seems to work very well.

I am wanting to get back the value="" value for a text input field. Getting the element is no problem, however using get_element_source does not return anything (empty string).

I have successfully used the get_element_source for a div and then parsed the contents using regEx, however in this case the div contains many input fields, and it seems like it would be better (at least for me, in this case) to manage getting/setting values as individual elements rather than having to parse the value data out of the div for a getter, and then map that to the individual text field elements for the setter (write_textfield()).


<div class="column">
                First Name:
<input type="text" value="Johnny" name="FirstName"/>
<!--many more of these label/input field pairs in this div-->

This may boil down to a limitation in the structure of the HTML and/or WebDriver, however I thought WebDriver could handle this case on it's own like in's assert_text_contains() which calls _get_text(elem).

Thanks in advance for any suggestions/patches.


Question information

English Edit question
selenium-simple-test Edit question
No assignee Edit question
Solved by:
Corey Goldberg
Last query:
Last reply:
Jason Dunckley (coloradojay) said : #1

After writing this and thinking about it more, I have decided to use actions._get_text() directly for now. It still might be a nice enhancement to expose it as an action.

Best Corey Goldberg (coreygoldberg) said : #2


WebElements have a `text` property. (I need to add WebElements to the documentation)

so you could do:

elem = get_element(tag="div" css_class="column")
print elem.text

I agree that `get_text()` is a nice enhancement. Feel free to add a bug/issue for it, and I will implement it:


Corey Goldberg (coreygoldberg) said : #5

get_text() is in trunk.