I am trying to use Watir (Phantom JS) to input a text in a textfield. But how can I select the textfield's ID if I am not just selecting on the class?
browser.text_field(id: "message").set # would this work? or do I need
browser.text_field(name: "#message").set? # Can I drop the "#" ?
Assume you have the following HTML:
By using an attribute of the
<input>
tag as a locator, you can input a string into the text_field. For example, you could use one of the following:As far as I know, the
set?
method only works for checkboxes and radio buttons. If you want to retrieve the string in the text_field, you could use thevalue
method: