Showing posts with label Selenium Regular Expression. Show all posts
Showing posts with label Selenium Regular Expression. Show all posts

Tuesday, May 8, 2012

Verify value in drop down list through regular expression

To find element drop down is easy but to find a drop down having some specific value in their list is difficult.
Go to www.ebay.in you will see there is drop down along with search text box.
How to verify a specific value "Collectibles" is in drop down list. Doing testing in Selenium, It will come as :  

How to select the value in drop down using regular expression.

There are situation when we need to select the drop down value with some partial text .
With the help of regular expression we can select the drop down value.

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