I can use
verifyTextPresent but that looks throughout the entire DOM. How do I limit the search to, for instance, a given div ?
I have some text which appears in multiple places and I want to be sure that the text I’m finding is the text I’m interested in .
I feel sure this must be a very common requirement but I can’t see it mentioned in the tuts etc.
you can use verifyElementVisible instead and you’ll be allowed to search in sub elements. Example:
String parentObjectPath = ".//div/div/div/ng-view/div/div/div/div/div/div"
String childObjectPath = "//div[text()='textYouLookFor']"
TestObject to = new TestObject().addProperty("xpath", ConditionType.EQUALS, parentObjectPath + childObjectPath)
Note double-slash at the beginning of child’s path, it means that you search only between child elements of a parent.
Excellent, thanks. I will try it out.