How to verify specific text exists within an attribute in Selenium IDE
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!
Ken
Updated on July 20, 2022Comments
-
Ken almost 2 years
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.