Reputation: 11
Cannot get input tag value with Selenium 2.0 webdriver and Ruby.
@driver.find_element(:id, "customer_info_last_name").text
returns nothing
and
@driver.find_element(:id, "customer_info_last_name").value
yields unknown method error
what is the correct way to retrieve the value of an input tag?
Upvotes: 1
Views: 4151
Reputation: 1
Also this should worked @driver.find_element(:id, "customer_info_last_name")['value']
Upvotes: 0
Reputation: 712
How about this?
@driver.find_element(:id, "customer_info_last_name").attribute('value')
Upvotes: 11
Reputation: 6354
you need to use driver.execute_script for getting inputs, instead of text or value. Can you try with below way
<input name="cheese" type="text"/>
cheese = driver.find_element(:name, "cheese")
element = driver.execute_script("return $('.cheese')[0]")
Please ping me if you get any error message
Upvotes: 0