How to handle/get/create the xpath of the objects having pseudo elements ::before or ::after

Hi Team,

Could please help me to handle the cross button of the PopUp Window.
I am not able to get its exact xpath.

I tried with Accept Alert inbuilt keyword, but still not working.

Thanks in advance.

Cross Button.png

Cross Button1.png

1 Like

In custom keywords you can used a TestObject with this xpath //div[@class=‘ngdialog-close’]
And next with this type of click
Actions action = new Actions(driver)


You want to select the

. Then the following XPath expression will work:


By the way, you wrote

the xpath of the objects having pseudo elements ::before or ::after

You are confused. The “pseudo element” is a terminology used in CSS selector. XPath specification does not define ::before and ::after.

In this forum comment, I typed this XPath expression:

This line is wrongly rendered by the Forum application as this:


The Forum application has a bug. It consumes a character sequence class='xxxx- away.

A workaround is to enclose the XPath in a pair of HTML code element: