Stanimir Yakimov
Stanimir Yakimov

Reputation: 884

How to verify text present with a special content using Selenium IDE?

How can I verify that some text contains a particular word using regular expressions in Selenium IDE? For example-if our text is

 JavaScript Book

how can I detect it using

 JavaScript

with a regular expression?

Upvotes: 1

Views: 7224

Answers (1)

Tetrinity
Tetrinity

Reputation: 1105

Regular expressions aren't necessary here. Selenium-IDE's verifyText command can do this using wildcards, which are denoted by an asterisk (*). Example script:

open | http://docs.seleniumhq.org/docs/02_selenium_ide.jsp#verifying-page-elements
assertText | xpath=id('verifying-page-elements')/h2 | *Page*
assertText | xpath=id('verifying-page-elements')/h2 | *some text*

The first assertText passes, while the second does not.

If you do want to use a regex, the syntax becomes:

assertText | xpath=id('verifying-page-elements')/h2 | regexp:.*Page.*

Upvotes: 4

Related Questions