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.
You can use
assertElementPresent,assertTextorassertAttribute, 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:If you want to assert that the linktext of the
<a href="www.example.com/foo">element isLink 1:If you want to assert that the element with link text “Link 1” contains
fooin itshref:Any questions welcome!