Can Ranorex search by ID or name instead of xpath?

Ask general questions here.
Posts: 18
Joined: Wed May 10, 2017 7:37 pm

Can Ranorex search by ID or name instead of xpath?

Post by Jimmyto » Wed Sep 13, 2017 4:40 pm

Hi All,

Ran into an issue with Xpath during a DevExpress update. We keep fixing the repository on every update and its becoming a pain. My question is if Ranorex can change the way it's searches for the object/element by ID. Maybe similar to Selenium where we can search by Element name, ID or xpath, etc.

Is this possible?

Thanks in advance!

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

Re: Can Ranorex search by ID or name instead of xpath?

Post by odklizec » Thu Sep 14, 2017 7:23 am


Yeah, sure, just delete the entire xpath between the root and last element, then add last element the ID you are looking for. Ranorex should happily find the element, but because the xpath will be too generic, it may take some time to find it.

Code: Select all

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

Ranorex Guru
Posts: 2683
Joined: Tue Feb 07, 2012 4:14 pm
Location: Austin, Texas, USA

Re: Can Ranorex search by ID or name instead of xpath?

Post by krstcs » Thu Sep 14, 2017 1:44 pm

To answer your question specifically, no, Ranorex (RX) only uses RanoreXPath (its version of XPath).

However, as Pavel said, you can simplify the xpath and use only the ID as a property and it will work exactly the same as By.ID() in Selenium (Se).

Also, if you are using UNIQUE IDs specifially, you can use "/div[#'myid']" instead of "div[@id='myid']" and it will be faster.

In addition, you might look into using rooted folders in your repo. This will help when needing to make changes to many elements at the same time because it abstracts parts of the path up into a parent folder so you can just change the folder. Think of this like having nested page objects in Se.

MyWebpage -> /dom[@domain='' and @state='complete']
-- MyHomePage (rooted folder) -> /div[#'myHome']
---- MyLoginButton -> /buttontag[@text='MyButtonText']

If you change MyHomePage's xpath, it also changes where Ranorex looks for MyLoginButton.
Shortcuts usually aren't...