Download presentation
Presentation is loading. Please wait.
Published byAndra Briggs Modified over 9 years ago
1
Test Automation For Web-Based Applications Portnov Computer School Presenter: Ellie Skobel
2
2 Day 2 Matching Text Patterns
3
describe the expected text Allow the user to describe the expected text, via the use of special characters. Frequently required by Selenese commands: assertText or waitForText assertTitle assertPrompt or waitForPrompt assertConfirmation or waitForConfirmation and others … Link locators can also utilize patterns
4
There are three ways to match patterns: Globbing - Utilized in filename expansion at a DOS or Unix/Linux command line Regular expressions - Supported by most high- level programming languages, and utilities grep, sed, and awk Exact – useful if you needed to look for an actual asterisk character, or square brackets
5
Only two special characters are supported in Selenium Asterisk (*): Translates to “match anything” ◦ Nothing ◦ Single character ◦ Many characters 1 Character Class [ … ]: Translates to “match any 1 character found inside the brackets PATTERN * Will match “PATTERN” PATTERN * Will match “PATTERN” PATTERN * Will match “PATTERNS” PATTERN * Will match “PATTERNS” PATTERN * Will match “PATTERN & MORE!” PATTERN * Will match “PATTERN & MORE!” [a-zA-Z0-9] Matches any alphanumeric character [a-zA-Z0-9] Matches any alphanumeric character [0-9] Matches any digit [0-9] Matches any digit [aeiou] Matches any lowercase vowel [aeiou] Matches any lowercase vowel
6
To specify a globbing pattern for a Selenese command prefix the pattern with “glob:” GLOB: is the default in Selenium IDE any one character exactly Unlike in DOS the (?) special character which translates to any one character exactly is not supported in Selenium CommandTargetValue clicklink=glob:*out assertTitleOrangeHRM*
7
Much more versatile then GLOB Many special characters and character grouping options supported. MATCH.any single character [ ]character class: any single character that appears inside the brackets *quantifier: 0 or more of the preceding character (or group) +quantifier: 1 or more of the preceding character (or group) ?quantifier: 0 or 1 of the preceding character (or group) {1,5}quantifier: 1 through 5 of the preceding character (or group) |alternation: the character/group on the left or the character/group on the right ( )grouping: often used with alternation and/or quantifier
8
Regular expression patterns need to be prefixed with “regexp:” or “regexpi:” REGEXP : is case-sensitive REGEXPI : is case-insensitive. CommandTargetValue clicklink=regexpi:.*out assertTitleregexp:OrangeHRM.* Note: Unlike GLOB, when using REGEXP the (*) character needs to be used together with a second qualifier.
9
regexp:.*[0-9]{1,2}:[0-9]{2} [ap]m ◦ Will match 12 hour time format hh:mm regexpi: ^[a-z]*$ ◦ Will match any 1 word in lower, upper, or mixed case. regexp:.* thinks (dogs|cats|fish) make great pets. http://www.regular-expressions.info/ http://www.regular-expressions.info/ 12:32 pm 9:19 pm 00:00 am HELLO Antidisestablishmentarianism cheese Alice thinks fish make great pets. 09377 thinks dogs make great pets! NOBODY thinks cats make great pets?
10
Useful when the string being matched contains special characters such as “** Disclaimers” Exact patterns need to be prefixed with “exact:” CommandTargetValue assertTextPresentexact: ** Not for resale
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.