Take the 2-minute tour ×

Is there a way to verify only part of text present?

If there is a text "Warning: A15P09 has not been activated." I need to verify the text is present. However, 'A15P09' is not always the same, so I cannot do something like

Selenium.IsTextPresent("Warning: A15P09 has not been activated.");

I might do something like:

Selenium.IsTextPresent("has not been activated.");

But is there another way to verify this in Selenium. Please let me know if there is.


share|improve this question

1 Answer 1

up vote 3 down vote accepted

You could use getText and then do any normal regex that your language supplies for examining that result.

Edit: And for some languages you can do isTextPresent on a pattern modified string. The documentation states:

Various Pattern syntaxes are available for matching string values:

glob:pattern: Match a string against a "glob" (aka "wildmat") pattern. "Glob" is a kind of limited regular-expression syntax typically used in command-line shells. In a glob pattern, "*" represents any sequence of characters, and "?" represents any single character. Glob patterns match against the entire string.

regexp:regexp: Match a string using a regular-expression. The full power of JavaScript regular-expressions is available.

exact:string: Match a string exactly, verbatim, without any of that fancy wildcard stuff.

If no pattern prefix is specified, Selenium assumes that it's a "glob" pattern.

share|improve this answer
@ borrible: so would Selenium.IsTextPresent("glob: Warning: * has not been activated."); work? –  Maya Jul 5 '11 at 16:31

Your Answer


