How to use xpath instead rxpath?

Best practices, code snippets for common functionality, examples, and guidelines.
Valeriy777
Posts: 19
Joined: Wed Jun 24, 2020 1:15 pm

How to use xpath instead rxpath?

Post by Valeriy777 » Mon Jul 06, 2020 8:54 pm

Hi,

I try to use Selenium WebDriver in the existing Ranorex project.
I created Selenium endpoint and launched the project throw him - all work well. But I can't use rxPath for element searching:
for example:

I can use

Code: Select all

 //span[@id='121']/span[@class='abc-ab']
But can't use

Code: Select all

//span[@id='121']/span[@class>'abc']
- failed element found exception occured.
Also I can;t use the native xpath:

Code: Select all

//span[@id='121']//span[starts-with(@class,'abc')]
- can't parse path exception

How to I can emerge from the situation?

User avatar
Support Team
Site Admin
Site Admin
Posts: 12150
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: How to use xpath instead rxpath?

Post by Support Team » Mon Jul 06, 2020 9:46 pm

Although very similar, RxPath is not Xpath and cannot be interchanged. RxPath is heavily based on Xpath but with many many years of improvements built-in. Capturing a Snapshot of the root dom repository item during runtime when using ./span[@class>'abc'] RxPath should help show why it is failing. If you need further assistance with this, please upload a compressed copy of the report.
1.png
1.png (23.24 KiB) Viewed 167 times
Regards,
Ned
.
Image

Valeriy777
Posts: 19
Joined: Wed Jun 24, 2020 1:15 pm

Re: How to use xpath instead rxpath?

Post by Valeriy777 » Mon Jul 06, 2020 10:21 pm

Support Team wrote:
Mon Jul 06, 2020 9:46 pm
Capturing a Snapshot of the root dom repository item during runtime when using ./span[@class>'abc'] RxPath should help show why it is failing. [/url].

Regards,
Ned
Thanks for your answer.

The problem in that I do not have errors when I create the path in the repository. All works well.
But when I switch to the Selenium endpoint - I got the error "Failed found the element /dom...../span[@id='121']/span[@class>'abc']"
When I use /dom.../span[@id='121'] all works well with Selenium endpoint also (but not with './span[@class>'abc']')

So:

1) 'span[@id='121']/span[@class>'abc']' works well with Ranorex endpoint
2) 'span[@id='121']/span[@class>'abc']' do not works with Selenium endpoint
3) 'span[@id='121']' works well with Ranorex endpoint
4) 'span[@id='121']' works well with Selenium endpoint

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 6236
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: How to use xpath instead rxpath?

Post by odklizec » Tue Jul 07, 2020 7:42 am

Hi,

Try this:
span[@id='121']/span[@class~'^abc']
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

Valeriy777
Posts: 19
Joined: Wed Jun 24, 2020 1:15 pm

Re: How to use xpath instead rxpath?

Post by Valeriy777 » Tue Jul 07, 2020 9:04 am

Thank you!
Resolved