I have a modal which I need to confirm is displayed or the text is present. However, this modal has duplicate id, class tags (used in other code). For example, to verify the text "Incorrect selection, please try again.Please select the US logo." the id and class are not unique tags?
<div id="errorMessagePanel" class="errorContainer yui-module yui-overlay yui-panel" style="visibility: inherit; width: 350px;">
<div class="hd" id="flyoutHd" style="cursor: auto;">Shopping Status</div>
<div class="bd alignLeft" id="flyoutBd">Incorrect selection, please try again. Please select the US logo.</div>
<a class="container-close" href="#">Close</a></div>
You could use the following to get the element by its text:
static content {
incorrectSelection { find("div", text: "Incorrect selection, please try again. Please select the US logo.") }
}
And then assert it's displayed:
assert incorrectSelection.displayed
Also if you find multiple elements being returned because of identical selectors you could rely on it's position in the returned array to check a particular element:
static content {
flyOuts { $("#flyoutBd") }
}
then:
assert.flyOuts[0].displayed