Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

On Selenium IDE, how to assert the text value in between tags?

Tags:

selenium-ide

The source code reads: <div class="qa">on</div>

And I want to assert in Selenium IDE that the value in between <div ...> and </div> is "on".

I tried to use assertValue and assertAttribute, but got an error with both commands. If I use assertElementPresent for the xpath=//div[@class='qa']/, it would pass, but it wouldn't assert that the value in between the <div>'s is "on".

like image 684
Shirley Zhang Avatar asked Sep 26 '22 17:09

Shirley Zhang


1 Answers

Use assertText (or verifyText if the test should not halt on failure):

assertText  xpath=//div[@class='qa']  exact:on

From the reference:

assertText(locator, pattern)

Generated from getText(locator)

Arguments:

  • locator - an element locator

Returns:

  • the text of the element

Gets the text of an element. This works for any element that contains text. This command uses either the textContent (Mozilla-like browsers) or the innerText (IE-like browsers) of the element, which is the rendered text shown to the user.

like image 78
Fabian Schmengler Avatar answered Sep 30 '22 06:09

Fabian Schmengler