[Wtr-general] How can I read alternate field attributes into a variable?
Paul Carvalho
tester.paul at gmail.com
Tue Apr 25 17:22:18 EDT 2006
Most of my Watir scripts generate their own random inputs (content and
length), but I always have to specify an upper limit for each data value
specified.
For example, a Create New User page has the following HTML for a User Name
input field:
<INPUT class=fieldLarge id=_ctl0_UserNameField maxLength=50
name=_ctl0:UserNameField>
and the script writes to it with the following code:
# Input a username that is at least 5 characters but no more than 50
chars in length
$ie.text_field(:name, /UserName/).set( random_input( 'text', 5+rand(46)
) )
So I have to [manually] specify in the script that it should contain no more
than 50 characters in length (i.e. upper limit of 5+45).
I would like to know if it is possible to have Ruby/Watir automatically read
the 'maxLength=##' attribute and assign that value to a variable that I can
then work with in the corresponding input commands?
If I can do that, then my scripts will be even more independent and free to
generate their own inputs of random length based on what the HTML says a
field's upper limit is.
I couldn't find anything in the Watir API Reference that looked like it
might do this. Could we add a feature to do this if there isn't a way now?
Paul.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://rubyforge.org/pipermail/wtr-general/attachments/20060425/448cda7d/attachment.html
More information about the Wtr-general
mailing list