0

I'm trying to match

An error has occurred

in

<div id="someid" class="alert alert-warning"> <button type="button" class="close" data-dismiss="alert">×</button> An error has occurred </div>

I tried various combinations of id=someid and //div[@id='someid'] but it keeps matching the "x" in the element.

pfa
  • 125
  • 17
  • It will do, as the text isn't inside a tag of it's own to separate it from the button there is no identifier you can use to get just the text, the div identifier you've been using will find everything inside the div, including the button text. the only way around this would be to wrap the text inside a

    or tag (if you have control of this), if not the only other way to get the script working would be to use a wildcard in your script at the start of the text you're trying to match, but then it's not really a great test as it means anything could appear before the text

    – Jsmith2800 Aug 18 '16 at 08:20
  • I don't have control. I'm just looking for an error message that I don't expect will change. Conversely the success text starts with Welcome so testing for the {non-}existence of that would work for me. I tried a couple of partial matches but couldn't get it to work. Still kinda new at selenium. Any chance of an example? – pfa Aug 18 '16 at 16:47
  • Never mind...think I got it. – pfa Aug 18 '16 at 19:32

0 Answers0