Xpath in GetElement doesn't work

Hi, I use the xpath below in GetElement, but it can’t detect the button, while trying in chrome console, it does detect the button, it just doesn’t work in openrpa. Is there anything wrong using this in openrpa xpath?

“xpath”: “//div[contains(@class,“dashboard-summary”)]//button[contains(@class, “btn-outline-success”)]”

If you’ve copied that string out of the selector window in openRPA it doesn’t work because wrong escapes you either got to escape the " via \" or use ’

“xpath”: “//div[contains(@class,‘dashboard-summary’)]//button[contains(@class, ‘btn-outline-success’)]”

or

“xpath”: “//div[contains(@class,\“dashboard-summary\”)]//button[contains(@class, \“btn-outline-success\”)]”

The syntax looks correct, but the XPath itself does not do what you think it does.

First, you find all DIVs that have a class dashboard-summary.

Then, you discard that by using // and not /, and search for all buttons that have a class btn-outline-success. So even if you have a button with class btn-outline-success outside the DIVs, you will also find those.

Also, in your example, you are using " inside the string " quote … that will not work. Either you need to use "" or you need to replace the " inside the string to '.

No it doesn’t?
the second // causes it to search only below the first find not the whole page. Atleast thats how xpath works, i never actually checked if the openRPA implementation works correctly.

But by design the difference between / and // is that one is searching directly below and the other is searching ALL BELOW.

God damn it, you are right… I was wrong.

/ means the button has to be a direct child; it cannot be nested in other elements.
// means the button can be inside any element, as long as it is inside the found div.

Sorry about that.