Friday, April 27, 2012

Patterns and Scripts

Most arguments required by the Selenium API fall into two categories:
I) Patterns and II) Scripts

I) Patterns : 1) glob (the default) and 2) regexp

1) glob:pattern
             * (anything/nothing)
             ? (any single character)
Example: verifyTitle | glob:Technical *Writing

2) regexp or regexpi (for case-insensitive match)
All JavaScript’s regular expression metacharacters are supported, including:
* (0 or more of preceding character)
+ (1 or more of preceding character)
? (0 or 1 of preceding character)
{n} (n of preceding character)
a|b (alternation: a OR b)
[aeiou] (character class: any one of the chars)

Example: Verifying search results for course CIS-200W
/* Allow 0 to ~ spaces between department & dash */
verifyTextPresent regexp:CIS *-200W-
/* Disallow course numbers 000-199 and 300-999 */
verifyTextNotPresent -[0-13-9][0-9][0-9].?-
/* Disallow course numbers 201-209 */
verifyTextNotPresent regexp:-20[1-9].?-

P.S : Validation :

1)  Verify text:
2      Verify date:
3      Alert pop up:
4      Dynamic selection :
5       

II) Scripts:

1) storeEval ( script, variableName )

Example: storeEval | this.browserbot.bodyText().match(/ of about +([0-9]+)\./)[1] | hits

2) storeExpression ( expression,variableName )

Example: storeExpression | javascript{this.browserbot.bodyTe xt().match(/of about +([0-9]+)\./)[1]} | hits

No comments: