XPath selecting help for a pop up dialog


I’m having issues correctly selecting a UI window that has popped up with a hyperlink that i need to click in my next test case action.

Have tried a few XPath values but none seem to correctly target the element. Can anyone help?


Quick guess: is it in an IFrame? There’s a selection for that in the object definition panel.


I dont think there is an iframe involved here. YOu can see from the screenshot its starts at body > div#sugarcrm

I can see two problems at the very first look.

  1. Do not use * (any tag) and div (specific tag) at the same time
  2. You must use full class name when searching by class - or use contains function
    (alert-success is only a part of class)
1 Like

Just tired below and still not working:

//div[@class=“alert” and @class=“alert-success” and @class=“alert-block” and @class=“closeable”]//span[@class=“text”]//a

//div[@class=“alert” and @class=“alert-success” and @class=“alert-block” and @class=“closeable”]//span//a

//div[@class=“alert” and @class=“alert-success” and @class=“alert-block” and @class=“closeable”]//a

It is not AND relation (well, in fact it is, but XPath doesn’t work like this).Simply copy the class attribute and use it in XPath.

//div[@class=“alert alert-success alert-block closeable”]//… and so on

Thanks your answer worked. Its strange because I’ve used the ‘and’ example in other places before and it seem to work.

Here was the working xpath for anyone needing example.

//div[@class=“alert alert-success alert-block closeable”]//span//a

You can use AND in XPath when you want to specify the element using multiple attributes, for example //div[@class="myClass" AND @id = "myId"]. When you have multiple classes, XPath evaluates it as class’ value - just a string, not a list of classes.

And ultimately, when you are confident of searching by only a single class out of X classes present in the element, use contains function.

//div[contains(@class, "alert-success")]

1 Like

Hi @Marek_Melocik

Could you please help me locate this element ? I am not able to fetch xpath for this element