Advice on making scripts runable on different devices

Mobile Testing, Android App Testing.
gilbar16
Posts: 109
Joined: Wed Mar 26, 2014 6:23 pm

Advice on making scripts runable on different devices

Post by gilbar16 » Tue Mar 15, 2016 7:10 pm

Hello,

Been testing on iOS devices and now ready to execute the same tests on Android devices.
Please share any tips/advice you may have to make scripts compatible with different mobile devices.

For example, in iOS, the Back, Forward, Refresh, Go buttons are detected by Ranorex under Base:.//toolbar
while
in Android, these buttons are detected under Base:.//container[@rid='Navigation']

Can these buttons have to be added separately in the Object Repository?

In SilkTest, the use of Multitag can take care of this.
So instead of defining two objects using:
Button RefreshIOS
tag ".//toolbar/blahblah"
Button RefreshAndroid
tag ".//container/blahblah"

you use: (in one object definition not two)
Button Refresh
multitag ".//toolbar/blahblah"
".//container/blahblah"


Is there some type of doing an "OR" in the RanoreXPath to handle both the "Base:.//toolbar" and "Base:.//container[@rid='Navigation']"?

More issues/differences in the List Items controls where in the iOS, they are recognized under .//iospicker in the iPhones but not in the iPads where they are recognized as Cells in UITableViewCells under a Container UITableViewWrapperView
while
in Android, the list items are under some Container 'custom' and defined as RadioButtons.
How do you handle this difference?



Thanks.
Gilbert
Last edited by gilbar16 on Thu Mar 17, 2016 9:01 pm, edited 1 time in total.

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

Re: Advice on making scripts runable on different devices

Post by odklizec » Wed Mar 16, 2016 8:36 am

Hi Gilbert,

I'm afraid, there is currently no support for logical operators for adapters. The only place where you can use logical operators are element attributes (things between [] brackets). As for your problem, the only thing you can probably do is to use a mix of relative parameters and wildcards (*, ?, //) and relationship operators.

So your example xpath could look like this:
".//*/blahblah"
".//?/blahblah"
".//blahblah"

However, you should be very careful about using wildcards, because if you simplify the xpath too much, it may take too long to find the appropriate element. Eventually, Ranorex may fail to uniquely identify the element you want.

I'm not experienced in Android/iOS testing, but I can imagine that their GUI has a very little in common? So it may be very hard to make the xpaths applicable for both platforms and at the same time make them reliable and maintainable in a long term run? Hope someone else with more iOS/Android experience could provide you with some more helps? But my general understanding is that it would be better to create a separate iOS and Android repository elements, maybe even separate repositories?

BTW, there is available a free Ranorex webinar regarding Mobile testing, which may also answer some of your questions (available here).

Good luck! ;)
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

lucian.teodorescu
Posts: 82
Joined: Fri Oct 24, 2014 10:58 am
Location: Bucharest

Re: Advice on making scripts runable on different devices

Post by lucian.teodorescu » Wed Mar 16, 2016 9:33 am

Hi,

I don't have a project like this yet (although I might soon), so I would share some tips that I've heard on a Testing Conference.
In order to have one Test Suite for different hardware:
- you can go with 2 repositories with exactly the same structure and names. Then you have some user-code to select the right repository, depending on device under test
- you can have alternatives in xPath like Pavel said (I don't find this particularly useful when dealing with Android and iOS)
- you can make all modules to find the correct item on spot, deciding which xPath to use via user code

I *think* the first of these three approaches is the most maintainable.
Or something else, that I didn't heard of, so far :oops:
Lucian Teodorescu
NetSun Software

gilbar16
Posts: 109
Joined: Wed Mar 26, 2014 6:23 pm

Re: Advice on making scripts runable on different devices

Post by gilbar16 » Wed Mar 16, 2016 6:12 pm

Hi Lucian,

Those are all good advices. Thank you.
Let's hope we hear some more from others who may have been using Ranorex on the different devices.

It's kind of so misleading though when you go to some websites and some people do claim or advertise that "one script you just completed on Android devices, for example, will work with iOS devices" - as if the objects they've added in the Repository for Android are all you need to run the same script on the iOS devices.

Another item that adds to the complexity of making the same scripts runable on different devices is another tool to support Cloud-based testing such as MobileLabs deviceConnect. Without having any add-in, Ranorex is basically unusable when you attempt to automate tests using devices connected to MobileLabs, as of this date. Maybe someday will have an add-in for Ranorex. So far, the add-in available is for HP UFT.

Thanks again for sharing your thoughts on this.

Regards,
Gilbert

zivshapirawork
Posts: 62
Joined: Wed Sep 24, 2014 7:47 am
Location: Israel

Re: Advice on making scripts runable on different devices

Post by zivshapirawork » Sun Mar 20, 2016 7:20 am

If you are developing the apps, then just identify by rid in android and accessibilityId in iOS. then you can place the the same value in those id, and use the (rid=.. or accessibiltyId=...) as the xpath (ignore the rest)

even if you are not developing the apps, you can still use the OR operator in the xpath and rely on the id's and nothing else.

that works fine.

gilbar16
Posts: 109
Joined: Wed Mar 26, 2014 6:23 pm

Re: Advice on making scripts runable on different devices

Post by gilbar16 » Tue Mar 22, 2016 1:47 am

zivshapirawork wrote:If you are developing the apps, then just identify by rid in android and accessibilityId in iOS. then you can place the the same value in those id, and use the (rid=.. or accessibiltyId=...) as the xpath (ignore the rest)

even if you are not developing the apps, you can still use the OR operator in the xpath and rely on the id's and nothing else.

that works fine.
Hi zivshapirawork,

How does this use of the 'OR' work when...
for iOS, the Back button has the Base:.//toolbar
while
for Android, the Back button has the Base:.//container[@rid='Navigation']

In other words, how can you do this 'OR' for objects coming from two different Bases?


Thanks.

Gilbert

zivshapirawork
Posts: 62
Joined: Wed Sep 24, 2014 7:47 am
Location: Israel

Re: Advice on making scripts runable on different devices

Post by zivshapirawork » Tue Mar 22, 2016 6:53 am

hi Gilbert

I think you can use a generic element (instead of toolbar etc.), and then the properties and their id's (in android the rid)

regards
Ziv

gilbar16
Posts: 109
Joined: Wed Mar 26, 2014 6:23 pm

Re: Advice on making scripts runable on different devices

Post by gilbar16 » Tue Mar 22, 2016 6:03 pm

Hi,

I'm not quite sure how this "use a generic element" is done.

In my case, this is how the RxBrowser presents it:
the button Back for iOS has a Base:.//tooolbar
/mobileapp[@title='ranorex.RxBrowser']//toolbar/button[@accessibilitylabel='Back']
while
in Android, the button Back has a Base:.//container[@rid='Navigation']
/mobileapp[@title='ranorex.RxBrowser']/form//container[@rid='Navigation']/button[@accessibilityid='Back']

So to make this generic to access either Back button, would something like below work?:
/mobileapp[@title='ranorex.RxBrowser']//*[[@rid='Navigation']/button[@accessibilityid='Back'] or /button[@accessibilitylabel='Back']]


Thanks.

Gilbert

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

Re: Advice on making scripts runable on different devices

Post by odklizec » Tue Mar 22, 2016 6:17 pm

Hi,

As mentioned before, there is currently no way to use logical operators between adapters. So the path you are looking for could look like this:
/mobileapp[@title='ranorex.RxBrowser']//button[@accessibilitylabel='Back' or @accessibilityid='Back']
Eventually, if the above path would be too slow either on Android or iOS, you can choose between these two paths (both should work on Android and iOS)...
/mobileapp[@title='ranorex.RxBrowser']//toolbar?/button[@accessibilitylabel='Back' or @accessibilityid='Back']
or like this:
/mobileapp[@title='ranorex.RxBrowser']//container?[@rid='Navigation']/button[@accessibilitylabel='Back' or @accessibilityid='Back']
The question mark in the path makes the attribute 'optional'. So if not found, Ranorex will continue to search the path as if there was no such adapter used.
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

gilbar16
Posts: 109
Joined: Wed Mar 26, 2014 6:23 pm

Re: Advice on making scripts runable on different devices

Post by gilbar16 » Tue Mar 22, 2016 8:35 pm

Hi Pavel,

Thanks so much for making this very clear. (logical operators between adapters -- being the key)

I wish Ranorex User Guide will have more of this kind of information/examples to make it easier to find ways of making Ranorex scripts runable on different devices/Operating Systems.

Sometimes we just cannot avoid using these controls/objects that are different from target devices when developers decide to create apps that forces you to use these controls instead of providing a link or a button that navigates back to the Home or previous screen or even Refresh the contents of the current screen.

Thanks again.

Gilbert

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

Re: Advice on making scripts runable on different devices

Post by Support Team » Wed Mar 23, 2016 8:25 am

Hello Gilbert,

I'm glad that you found a solution for you issue. Just to mention, there is already information about logical operator within the RxPath available. Please check out the following section within our user guide: http://www.ranorex.com/support/user-gui ... xpath.html

Sincerely,
Robert
.
Image