0

How can I select a XPath that contains a text with both quote & comma character?

I have to find an element if the text contains =Yes, It's OK

My XPath does not save in ranorex tool even though if i put the text inside the double quotes like below

//span[text()="Yes, It's OK"]

So how can I save this xpath that uses "".in Ranorex

zx485
  • 28,498
  • 28
  • 50
  • 59
  • i have voted to close this question as "needs debugging details", specifically i want the HTML you are trying to parse. – hanshenrik Dec 21 '22 at 12:55
  • The XPath is fine, the problem will be the context in which it appears. I've no idea what Ranorex is, so can't help you with that. – Michael Kay Dec 21 '22 at 14:50

1 Answers1

0

your use of double-quotes is correct. if

//span[text()="Yes, It's OK"]

doesn't match, it might be because the xpath engine has a lowercase bug (i have encountered PHP+DOMXPath+libxml2 systems where it would only match lowercase text even for text with uppercase characters, never quite figured out the problem there), or it might be because the text has hidden whitespace you're not aware of, maybe it actually has a hard-to-spot whitespace at the start or the end? anyway maybe contains() will work:

//span[contains(text(),"Yes, It's OK"]

or.. if it has the lowercase-issue i have encountered in the wild once before, maybe this will work:

//span[contains(text(),"yes, it's ok"]

(that really shouldn't be required, but i have been in that situation once before, and that was years ago, and that was... probably php5)

hanshenrik
  • 19,904
  • 4
  • 43
  • 89