Dave Hoover wrote:
>On 8/15/06, Astha Raj <[EMAIL PROTECTED]> wrote:
>
>
>>What I need do to
>>only look for the string which ends with the given section. For example, I
>>have two form fields with id like
>>
>>FormName_Name1 and FormName_Name1New
>>
>>So when I use the Watir statement like –
>>e.text_field(:id,/_Name1/).set("astharaj") – it will put the same in both –
>>right? I want it to just set for first field (FormName_Name1). How can I do
>>this? Any suggestions would be great.
>>
>>
>
>Use the \A and \Z anchors to match the beginning and end of strings,
>respectively. I believe the answer to your question is
>
> e.text_field(:id, /_Name1\Z/).set("astharaj")
>_______________________________________________
>Wtr-general mailing list
>[email protected]
>http://rubyforge.org/mailman/listinfo/wtr-general
>
>
actually, the easier way is:
e.text_field( :id, /_Name1$/.set( "ashtharaj" )
$ is the regex standard way of denoting END of line.
^ is the regex standard way of denoting BEGINNING of line.
I've never seen \A & \Z before. I would try to use standard regex
things ... that way you aren't stuck when you eventually grow into using
other programming languages which don't support that non-standard extension.
... just my $0.02
jd
_______________________________________________
Wtr-general mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/wtr-general