0

I have the 2 Xpath below that don't have Id nor class. I want to find the element with "id=RTY_183" or "id=RTY_189".

//*[@id='RTY_183']
//*[@id='RTY_189']

I've tried regex and or but don't work, like this:

with OR

document.evaluate("//*[@id='RTY_183' or @id='RTY_189' ]", document.body, null, 9, null).singleNodeValue.click();

and with regex

document.evaluate("//*[@id='RTY_18[3,9]']", document.body, null, 9, null).singleNodeValue.click();

Is possible? what I'm doing wrong?

Thanks for any help

Barmar
  • 741,623
  • 53
  • 500
  • 612
Ger Cas
  • 2,188
  • 2
  • 18
  • 45
  • Possible duplicate of [GetElementByID - Multiple IDs](https://stackoverflow.com/questions/14408891/getelementbyid-multiple-ids) – Sudhir Ojha May 24 '19 at 06:00
  • @SudhirOjha I've tried from the lik you shared like this `document.querySelectorAll("#RTY_183, #RTY_189").click();` but doesn't work. May you help me to fix what I'm fdoing wrong please. – Ger Cas May 24 '19 at 06:17
  • Please post your code here. – Sudhir Ojha May 24 '19 at 06:18
  • @SudhirOjha Sorry which code? I already show the code I tested in previous comment. – Ger Cas May 24 '19 at 06:21

1 Answers1

0

Have you tried below Xpath.

//*[starts-with(@id,'RTY_18')]
KunduK
  • 32,888
  • 5
  • 17
  • 41
  • Thank you for your answer. The Xpath you suggest can be used with `document.querySelectorAll()` or with `document.evaluate()`? But the issue is there are more Xpath in the same window that are like `RTY_182, RTY_185, RTY_187, etc` and from all I only want to do click on the two ending in 3 or 9. – Ger Cas May 24 '19 at 11:54