jabastar
jabastar

Reputation: 11

Ruby Selenium 2.0 cannot get value of input tag

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

Answers (3)

roomer
roomer

Reputation: 1

Also this should worked @driver.find_element(:id, "customer_info_last_name")['value']

Upvotes: 0

grumpasaurus
grumpasaurus

Reputation: 712

How about this?

@driver.find_element(:id, "customer_info_last_name").attribute('value')  

Upvotes: 11

AMIC MING
AMIC MING

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

Related Questions