# Xpath in GetElement doesn't work

**URL:** <https://discourse.openiap.io/t/xpath-in-getelement-doesnt-work/3262>\
**Category:** OpenRPA\
**Created:** [April 23, 2026, 2:30am UTC](https://discourse.openiap.io/t/xpath-in-getelement-doesnt-work/3262 "2026-04-23T02:30:52Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![hw.chan](https://discourse.openiap.io/letter_avatar_proxy/v4/letter/h/dc4da7/32.png) [@hw.chan](https://discourse.openiap.io/u/hw.chan)\
**Post date:** [April 23, 2026, 2:30am UTC](https://discourse.openiap.io/t/xpath-in-getelement-doesnt-work/3262/1 "2026-04-23T02:30:52Z")

</div>

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”)]”

---

<div class="post-metadata">

**Author:** ![Morphyum](https://discourse.openiap.io/user_avatar/discourse.openiap.io/morphyum/32/2012_2.png) [@Morphyum](https://discourse.openiap.io/u/Morphyum)\
**Post date:** [April 23, 2026, 6:57am UTC](https://discourse.openiap.io/t/xpath-in-getelement-doesnt-work/3262/2 "2026-04-23T06:57:08Z")

</div>

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\”)]”

---

<div class="post-metadata">

**Author:** ![Allan\_Zimmermann](https://discourse.openiap.io/user_avatar/discourse.openiap.io/allan_zimmermann/32/12_2.png) [@Allan\_Zimmermann](https://discourse.openiap.io/u/Allan_Zimmermann)\
**Post date:** [April 23, 2026, 7:00am UTC](https://discourse.openiap.io/t/xpath-in-getelement-doesnt-work/3262/3 "2026-04-23T07:00:45Z")

</div>

~~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 `'`.

---

<div class="post-metadata">

**Author:** ![Morphyum](https://discourse.openiap.io/user_avatar/discourse.openiap.io/morphyum/32/2012_2.png) [@Morphyum](https://discourse.openiap.io/u/Morphyum)\
**Post date:** [April 23, 2026, 7:05am UTC](https://discourse.openiap.io/t/xpath-in-getelement-doesnt-work/3262/4 "2026-04-23T07:05:00Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Allan\_Zimmermann](https://discourse.openiap.io/user_avatar/discourse.openiap.io/allan_zimmermann/32/12_2.png) [@Allan\_Zimmermann](https://discourse.openiap.io/u/Allan_Zimmermann)\
**Post date:** [April 23, 2026, 7:07am UTC](https://discourse.openiap.io/t/xpath-in-getelement-doesnt-work/3262/5 "2026-04-23T07:07:56Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![system](https://discourse.openiap.io/uploads/default/original/2X/a/a1ca7b164ac9a826839704d9ac82c7b5e6bcf557.png) [@system](https://discourse.openiap.io/u/system)\
**Post date:** [April 30, 2026, 7:08am UTC](https://discourse.openiap.io/t/xpath-in-getelement-doesnt-work/3262/6 "2026-04-30T07:08:16Z")

</div>

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.
