Selenium: Part of text present
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 d开发者_运维百科o 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.
Thanks!
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.
精彩评论