Re: Validating multiple contents
- From: Henrik Nyh <henrik@xxxxxx>
- Date: Sat, 18 Oct 2008 03:30:52 -0500
On Fri, Oct 17, 2008 at 3:50 PM, Matthew Moss <matt@xxxxxxxxx> wrote:
On Oct 17, 2008, at 12:15 AM, Bala Krishnan wrote:
Hi
If we want to validate result page with single text content we will
use
ie.text.include?(" Particular content ")
suppose if i want to validate page with multiple content like
German rails
NGINX
how to use ruby for this validation?
["German rails", "NGINX"].any? { |str| ie.text.include?(str) }
This will return true if any of the strings are found in ie.text. Replace
any? with all? to return true only if all of the strings are found.
More obscure but kind of cute:
Regexp.union("German rails", "NGINX").match(ie.text)
Regexp.union creates a regexp that matches any of the parts. They're
regexp-escaped, too.
.
- References:
- Validating multiple contents
- From: Bala Krishnan
- Re: Validating multiple contents
- From: Matthew Moss
- Validating multiple contents
- Prev by Date: Re: Shoes GUI - downloading site, using reg exs on body
- Next by Date: Re: Shoes GUI - downloading site, using reg exs on body
- Previous by thread: Re: Validating multiple contents
- Next by thread: Where does merb store the files for a new app?
- Index(es):
Relevant Pages
|