Selenium WebDriver Java Framework Course Limited Time Offer for $20

Selenium WebDriver Java Framework Course Limited Time Offer for $20



Using Globbing Pattern and Regular Expression with Selenium IDE

In some test cases, QA Engineers need to verify text or number patterns by using verifyTextPresent, verifyTitle, verifyAlert, assertConfirmation, verifyText, and verifyPrompt. Selenium locators can utilize pattern to describe special characters, and dynamic texts to verify what text is expected rather than having to specify that text exactly.


There are three types of patterns: globbing, regular expressions, and exact.


  • * which translates to “match anything,” i.e., nothing, a single character, or many characters.
  •     [ ] which translates to “match any single character found inside the square brackets.
  •     [aeiou] matches any lowercase vowel
  •     [0-9] matches any digit
  •     [a-zA-Z0-9] matches any alphanumeric character

When using globbing pattern, for a Selenese command, you can prefix the pattern with a glob: label

Command Target Value
click id=glog:login*login_username  

Regular Expression Patterns:

Regular expression patterns are the most powerful of the three types of patterns that Selenium supports. Regular expressions are also supported by most high-level programming languages, many text editors, and a host of tools,  In Selenium, regular expression patterns allow a user to perform many tasks that would be very difficult otherwise. For example, suppose your test needed to ensure that a particular table cell contained nothing but a number. regexp: [0-9]+ is a simple pattern that will match a decimal number of any length.

. 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

Regular expression patterns in Selenium need to be prefixed with either regexp: or regexpi:. The former is case-sensitive; the latter is case-insensitive.

Command Target Value
click id=regexp:login*login_username  

Some examples for regular expression:

Zip Codes: \b[0-9]{5}(?:-[0-9]{4})?\b  (matches 5 digit zip codes)

Any Html tag : </?[a-z][a-z0-9]*[^<>]*>  (matches any html tag in the bracket <>) 

For more information, visit Regular Expression site:

Exact Pattern:

Exact pattern means that users need to verify the exact texts or numbers. It uses no special characters at all.