I just started using Watir to write some simple tests for my web application.
First thing I want to do is to populate an login form with an email input element of type "email" with SafariWatir on OS X.
This won't work:
browser.text_field(:id, "email").set('my@email.com')
Trace:
/Library/Ruby/Gems/1.8/gems/safariwatir-0.4.0/lib/safariwatir/scripter.rb:661:in `execute': Unable to locate TextField, using :id and "email" (Watir::Exception::UnknownObjectException)
from /Library/Ruby/Gems/1.8/gems/safariwatir-0.4.0/lib/safariwatir/scripter.rb:303:in `focus'
from /Library/Ruby/Gems/1.8/gems/safariwatir-0.4.0/lib/safariwatir.rb:525:in `set'
from test.rb:10
I assume that the element is not matched because of the different type attribute value. The documentation does not state any specification for this kind of elements. Any ideas?
Thanks!
Update: adding (reformatted) HTML sample based on user's comment that they are testing pinganalytics
<form action="http://pingalytics.com/" method="post" accept-charset="utf-8">
<p>
<label for="email">Email</label>
<input type="email" name="email" value="" id="email" autofocus="" />
</p>
<p>
<label for="password">Password</label>
<input type="password" name="password" value="" id="password" />
</p>
<input type="submit" name="login" value="Log in with Pingdom" class="primary" />
<p>
<a href="https://www.pingdom.com/signup/">
Sign up
</a>
, or
<a href="https://pp.pingdom.com/index.php/login" title="Reset your Pingdom password">
recover your password
</a>
.
</p>
</form>