Selenium: test if element contains some text

Mark W picture Mark W · Mar 29, 2012 · Viewed 49.3k times · Source

With Selenium IDE, how can I test if an element's inner text contains a specific string? For example:

<p id="fred">abcde</p>
'id=fred' contains "bcd" = true)

Answer

Petr Janeček picture Petr Janeček · Mar 29, 2012

The Selenium-IDE documentation is helpful in this situation.

The command you are looking for is assertText, the locator would be id=fred and the text for example *bcd*.