Try:

$ie.text.include?("#{check}")

-----Original Message-----
From: mohe [mailto:j.mohanpra...@gmail.com] 
Sent: Wednesday, December 02, 2009 1:49 PM
To: Watir General
Subject: [wtr-general] Re: regular expression in $ie.text.include? issue

'check' variable is a string.actually i need to verify some text in
all the pages.so i wrote a function and pass the text through the
variable "check".i want to use the regular expression for the text as
it is failed in some pages even the particular text is displayed in
page.

On Dec 2, 2:59 pm, Ethan <notet...@gmail.com> wrote:
> String#scan is not really appropriate for just testing whether a string
> matches a regexp (it is certainly possible, but is overkill). the =~
> operator should suffice:
>
> def verify_field(check,result)
>  if $ie.text =~ Regexp.new(check)
>    $dt.WriteData("#{result}","Sheet1", "Pass")
>  else
>    $dt.WriteData("#{result}","Sheet1", "Fail")
>  end
> end
>
> I'm curious if the 'check' variable is a string, or a regexp, though - if
> it's a regexp, you don't need to do Regexp.new; if it's a string, that seems
> like an odd thing to pass in to match as a regexp. maybe you just want
> $ie.text.include?(check)
>
> -Ethan
>
>
>
> On Wed, Dec 2, 2009 at 15:40, John Fitisoff <jfitis...@yahoo.com> wrote:
> > try ie.text.scan(regexp)
>
> > if ie.text.scan(/foo/).length > 0
> >  ...write some data...
> > end
>
> > btw, this isn't a watir issue, it's a ruby issue. IE#text just returns a
> > string and a string's include? method doesn't accept a regex as an argument,
> > at least my installed ruby version doesn't support it.
>
> > --- On Wed, 12/2/09, mohe <j.mohanpra...@gmail.com> wrote:
>
> > > From: mohe <j.mohanpra...@gmail.com>
> > > Subject: [wtr-general] regular expression in $ie.text.include? issue
> > > To: "Watir General" <watir-general@googlegroups.com>
> > > Date: Wednesday, December 2, 2009, 12:22 PM
>
> > > regular expression is not working in $ie.text.include?.i am
> > > getting
> > > error message "`include?': can't convert Regexp into
> > > String
> > > (TypeError)" for the following code.any idea please.?
>
> > > def verify_field(check,result)
> > >   if $ie.text.include?(Regexp.new(check))
> > >     $dt.WriteData("#{result}","Sheet1", "Pass")
> > >   else
> > >     $dt.WriteData("#{result}","Sheet1", "Fail")
> > >   end
> > > end
>
> > > --
> > > You received this message because you are subscribed to the
> > > Google Groups "Watir General" group.
> > > To post to this group, send email to watir-general@googlegroups.com
> > > Before posting, please read the following guidelines:
> >http://wiki.openqa.org/display/WTR/Support
> > > To unsubscribe from this group, send email to
> > watir-general-unsubscr...@googlegroups.com
> > > For more options, visit this group at
> >http://groups.google.com/group/watir-general
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Watir General" group.
> > To post to this group, send email to watir-general@googlegroups.com
> > Before posting, please read the following guidelines:
> >http://wiki.openqa.org/display/WTR/Support
> > To unsubscribe from this group, send email to
> > watir-general-unsubscr...@googlegroups.com
> > For more options, visit this group at
> >http://groups.google.com/group/watir-general- Hide quoted text -
>
> - Show quoted text -

-- 
You received this message because you are subscribed to the Google Groups 
"Watir General" group.
To post to this group, send email to watir-general@googlegroups.com
Before posting, please read the following guidelines: 
http://wiki.openqa.org/display/WTR/Support
To unsubscribe from this group, send email to 
watir-general-unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/watir-general

-- 
You received this message because you are subscribed to the Google Groups 
"Watir General" group.
To post to this group, send email to watir-general@googlegroups.com
Before posting, please read the following guidelines: 
http://wiki.openqa.org/display/WTR/Support
To unsubscribe from this group, send email to 
watir-general-unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/watir-general

Reply via email to