try using an 'until' with the use of =~ /regex/, it will make it clearer also you may want add more detail to the regex such as it case sensitive? /i makes the regex match case insensitive.
-Pierre Garigue -----Original Message----- From: Paul Carvalho [mailto:[EMAIL PROTECTED] Sent: Thursday, March 09, 2006 11:58 AM To: [email protected] Subject: [Wtr-general] Negative Loop Regular Expression checks Hello all, I'm having difficulty programming a negative loop. That is, while something isn't there, then do this. Here's an example: I've scripted Watir to randomly select a report, and then when the report comes up it checks the month of the report. If it's not the month I want, I have the script click the "Previous" link until it finds the report I want. Here's the code : ---- while $ie.frame('MainWindow').span(:id, /ReportingPeriodValueLabel/).text != 'Dec 2005' $ie.frame('MainWindow').link(:text, 'Previous').click end ---- This works - most of the time. The problem is that if the report happens to come up on particular page, the label value = 'Jan - Dec 2005' and the check above *always* fails. I tried to change the comparison value to a regex but that didn't work. That is, "while blahblah.text != /Dec 2005/" will be True even when the label = 'Dec 2005'! (That's no good. I expect it to be false and break out of the loop.) I think I'm missing something in the use of regular expressions that I just don't know yet. (I'm just starting to learn about them - they are *way* handy.) Paul. _______________________________________________ Wtr-general mailing list [email protected] http://rubyforge.org/mailman/listinfo/wtr-general
