How do I send key stroke Enter in Watir

user1771980 picture user1771980 · Feb 13, 2013 · Viewed 9k times · Source

I need to automate the action of hitting 'Enter' key on keyboard after entering a text in a text field. I tried @browser.send_keys :enter but that does not do the action. also have tried @browser.text_field(:name => 'q').send_keys :enter or @browser.text_field(:name => 'q').focus and then send_keys. But has not helped.

@browser.send_keys("{ENTER}")

does not help this too, this actually types ("{ENTER}")

Please let me know other ways of doing?

Answer

Željko Filipin picture Željko Filipin · Feb 13, 2013

browser.send_keys :enter should do the job. Please provide link to the page, link to a similar page, or relevant HTML.