Ardent Development Podcast artwork

Forms Not Submitting With Watir?

Ardent Development Podcast

English - September 29, 2009 13:44 - ★★★★★ - 1 rating
Technology Homepage Apple Podcasts Google Podcasts Overcast Castro Pocket Casts RSS feed


Watir, pronounced water, is an open-source (BSD) library for automating web browsers. It allows you to write tests that are easy to read and maintain. It is simple and flexible. Watir drives browsers the same way people do. It clicks links, fills in forms, presses buttons. Watir also checks results, such as whether expected text … Continue reading Forms Not Submitting With Watir?


The post Forms Not Submitting With Watir? appeared first on Ardent Development Podcast.

Watir, pronounced water, is an open-source (BSD) library for automating web browsers. It allows you to write tests that are easy to read and maintain. It is simple and flexible.


Watir drives browsers the same way people do. It clicks links, fills in forms, presses buttons. Watir also checks results, such as whether expected text appears on the page.


http://watir.com/

A great use for Watir is to automate tedious form filling during development / developer testing.  Letâ€s say you have a simple form like the following to submit a search query to Google:



<html>
<body>
<form id="search_form" action="http://google.com/search">
  <input name="q" value="derekhat" />
  <input type="submit" name="submit" />
</form>
</body>
</html>



The Ruby code to submit a form is pretty simply:



Browser.goto "file:///C:/Users/derek/Desktop/submit.html";
Browser.form(:id, "search_form").submit;



The only problem is that this wonâ€t work in this case.  The reason:  thereâ€s an input field called submit that hides the formâ€s submit method.  The workaround is easy:



Browser.goto "file:///C:/Users/derek/Desktop/submit.html";
Browser.button(:name, "submit").click;



Happy testing!


The post Forms Not Submitting With Watir? appeared first on Ardent Development Podcast.