Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to verify specific text exists within an attribute in Selenium IDE

I would like to verify that the URL in a href attribute contains certain text. For instance, if the URL contains "foo," the test should continue. If it does not contain "foo," the test should stop. It's unclear to me whether I should be using assertAttribute or assertText, or something else. I'm also a little unclear as to what the exact syntax would be.

<a href="www.example.com/foo">Link 1</a>
<a href="www.example.com/questions">Link 2</a>

Any guidance on this would be much appreciated.

like image 461
Ken Avatar asked Jul 20 '12 03:07

Ken


1 Answers

You can use assertElementPresent, assertText or assertAttribute, it depends on your exact usage.

If you want to assert that there is an <a href="www.example.com/foo"> element somewhere on the page:

assertElementPresent | css=a[href*=foo]

If you want to assert that the linktext of the <a href="www.example.com/foo"> element is Link 1:

assertText | css=a[href*=foo] | Link 1

If you want to assert that the element with link text "Link 1" contains foo in its href:

assertAttribute | link=Link 1@href | *foo*

Any questions welcome!

like image 175
Petr Janeček Avatar answered Sep 30 '22 05:09

Petr Janeček