tic
tic

Reputation: 147

Ruby/Watir - Clicking inside of a text box

How do you use Watir to manually click inside of a text box? This is so that I can send keys using the send_keys method instead of using the text_field.set method.

Upvotes: 0

Views: 1835

Answers (1)

Justin Ko
Justin Ko

Reputation: 46836

If you want to send keys to a specific element (eg text field), you should not need to click it first. The Watir API allows you to send keys to a specific element. For example:

text_field(:id => 'my_id').send_keys('a')

However, if you need to click the element to initiate some javascript, then try:

text_field(:id => 'my_id').click
text_field(:id => 'my_id').send_keys('a')

Upvotes: 1

Related Questions