spacecodeur
spacecodeur

Reputation: 2406

Selenium IDE, check (assert) if a dynamic element contains a specific text

In my website, I have a form who add a new 'td' element in a table. The content of td elements contains a random identifier

After submit, I have an html structure like that :

<table>
    <tr>
        <td class="a">edazdad</td>
        <td class="b">dscsdcsdc</td>
        ...
        <td class="n">rkjrlejf</td>
    </tr>
</table>

So, I want add an assert test in selenium IDE. I want check if my new element is in my table html element.

I try :

AssertText

or

AssertText

How can I do that ? =)

Upvotes: 0

Views: 2621

Answers (1)

Antesser
Antesser

Reputation: 669

First of all something is really wrong with your Selenium IDE since assertText is acting like assertAlert. Are you sure that you are using correct command? Because the second example in you question seems totally Ok.

Secondly if because of some strange and weird problem assertText is really not working here is the workaround:

click | //table/tr/td[contains(text(), 'dscsdcsdc')]

It will fail if there is no element with 'dscsdcsdc' because you are already verifying that element has the text by locating element containing the text.

BUT Once again

assertText | //table/tr/td[contains(text(), 'dscsdcsdc')]/text() | dscsdcsdc

should work. Check the command please

Good luck.

Upvotes: 1

Related Questions