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!
Jimmy
Can Ranorex search by ID or name instead of xpath?
Re: Can Ranorex search by ID or name instead of xpath?
Hi,
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.
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
form[@id='root_form_name']//button[@id='name_of_button']
Pavel Kudrys
Ranorex explorer at Descartes Systems
Please add these details to your questions:
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
Re: Can Ranorex search by ID or name instead of xpath?
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='www.mydomain.com' 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.
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='www.mydomain.com' 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...