Learning Resources
 

Globs


Since the days of DOS, we have been using globbing. What is globbing? Remember the days you were searching files in DOS by using the command *.doc or  De*.doc and so on. This is where you have used globs. So let’s see how Selenium supports globbing.

Globbing in Selennium is possible with the following set of characters

i)         * (asterisk)

  • It is used to match any number of characters. E.g. *.doc will indicate a.doc or abhilash.doc

ii)          ? (question mark)

  • It is used to match a single character. E.g. Pe?.doc will indicate Pet.doc. It supports just a single character.

iii)        [ ] (square brackets)

  • Typically a square bracket is used to denote a class of characters or set of characters.
  • [a-z] means a set of lowercase alphabets
  • [A-Z] means a set of uppercase alphabets
  • [0-9] indicates a set of numeric values

Suppose we want to find/ search for the text “region” or “regional”, then we could use it as reg* . In Selenium, that would mean the following

Command Target Value
verifyTextPresent Glob: reg*