How to identify objects other than xpath

Best practices, code snippets for common functionality, examples, and guidelines.
ninaddande
Posts: 15
Joined: Mon Apr 25, 2016 7:54 pm

How to identify objects other than xpath

Post by ninaddande » Tue Jun 07, 2016 8:41 pm

Hi Folks,

I am working on automation of a web application. As far as I searched I got to know that we can identify objects only with Ranorex Xpath.

Is it possible to identify object with just name, Id, ClassName, Value attributes which will be faster search as compared to Xpath. Could you please guide me in this regard.

Like in Selenium we can search an object or web element with By.Name, By.Value etc etc.

Please post your reply if anybody has worked on this as it will be a great help.

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

Re: How to identify objects other than xpath

Post by krstcs » Tue Jun 07, 2016 9:16 pm

Ranorex MUST use XPath for object identification, but you can still use the same attributes (which is all Selenium is doing in the background). And, RanoreXPath is as fast or faster than Selenium, in my experience, if your XPath is done right.

To get an element (let's say a button named 'ButtonName' that is in a div inside the body tag) by name:
DOMAIN -> /dom[@domain='www.mysite.com']
---- BODY -> /body
-------- DIV -> /div
------------ MyButton -> /button[@name='ButtonName']

And if your developers implement unique ids for the important elements (which they should), then you can do this:
DOMAIN -> /dom[@domain='www.mysite.com']
---- MyButton -> //button[#'myButtonId']

This is even faster than the full path above, and usually faster than Selenium.

Selenium get's it's speed by not implementing/manipulating some of the UI that Ranorex does. You can speed up Ranorex some, but really automation isn't about speed, it's about consistency.

From my experience, Ranorex is much more powerful and versatile as it can be used on other types of automation besides web sites. But Ranorex is also only available on Windows, so you can't test *nix-based applications or browsers, but really, there are only a couple of main browser engines being used anymore and they are all available on Windows and can be tested with Ranorex, so you're not missing anything. Plus Ranorex can test on iOS and Android.
Shortcuts usually aren't...

ninaddande
Posts: 15
Joined: Mon Apr 25, 2016 7:54 pm

Re: How to identify objects other than xpath

Post by ninaddande » Fri Jun 10, 2016 7:05 pm

Thanks for your response. I did the same way you suggested. Then it may be a problem with my application. I will try on any other web application and will confirm you.