Nro
Nro

Reputation: 349

How can I extract an HTML form value?

Hi I have the following in a page:

input id="cu_first_name" class="input_text" type="text" value="test_name" name="cu_name"

I am trying to extract the value and print it in python. I use:

username = driver.find_element_by_id("cu_first_name")

print username.text

But this will not work since there is no actual text there, I need the "test_name" to be printed, pls help me!

Upvotes: 0

Views: 74

Answers (1)

That1Guy
That1Guy

Reputation: 7233

You've gotten the element by id. From there, you need to get the element's attribute. Give the following a try:

username = driver.find_element_by_id("cu_first_name")
value = username.get_attribute('value')

print value

Upvotes: 2

Related Questions