Anrdoid studio emulator and Tracking element in Mobile app

Best practices, code snippets for common functionality, examples, and guidelines.
mmahra
Posts: 37
Joined: Wed Feb 26, 2020 2:17 pm

Anrdoid studio emulator and Tracking element in Mobile app

Post by mmahra » Wed Mar 18, 2020 5:35 am

Hello,

I am using Android studio as emulator to Ranorex and I am stuck somehow on a Test where I do search and should verify the returned result.
since Spy captures the UI elements first , I am not able to identify my returned search result.

any work around for that?

xpath: /mobileapp[@title='com.jivesoftware.daily.prodinternal']/form[@title='MainActivity']/androidelement[@rid='content']/androidelement/container[@containertype='Linear']/?/?/container[@containertype='Frame']/?/?/container[@containertype='Linear']/container[@containertype='Frame']
Last edited by mmahra on Thu Mar 19, 2020 11:09 am, edited 1 time in total.

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

Re: Anrdoid studio emulator and Tracking element in Mobile app

Post by odklizec » Wed Mar 18, 2020 7:52 am

Hi,

At first, please post a Ranorex snapshot (NOT screenshot) of your app. Screenshot is unfortunately not very helpful.
Generally speaking, if Spy always picks an "infront" object, and not the one you are looking for, then what you must do is to search the element you are looking for manually. Simply expand the tree, and open the items one by one and check the screenshot of each individual element. This way you should be able to find the element you are looking for.
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

mmahra
Posts: 37
Joined: Wed Feb 26, 2020 2:17 pm

Re: Anrdoid studio emulator and Tracking element in Mobile app

Post by mmahra » Wed Mar 18, 2020 9:16 am

Thank you Pavel for your reply.

Expanding the tree is not helping much here as I was not able to find the element.

PFA
Last edited by mmahra on Thu Mar 19, 2020 11:09 am, edited 1 time in total.

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

Re: Anrdoid studio emulator and Tracking element in Mobile app

Post by odklizec » Wed Mar 18, 2020 9:44 am

Hi,

Well, I can only guess that you are looking for this element?...
/mobileapp[@title='com.jivesoftware.daily.prodinternal']/form[@title='MainActivity']//androidelement[@platformclass='android.support.v7.widget.CardView']/container[@containertype='Linear']/container/text[@text='myTATSpace']
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

mmahra
Posts: 37
Joined: Wed Feb 26, 2020 2:17 pm

Re: Anrdoid studio emulator and Tracking element in Mobile app

Post by mmahra » Wed Mar 18, 2020 9:56 am

This XPath is failing
Last edited by mmahra on Thu Mar 19, 2020 11:08 am, edited 1 time in total.

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

Re: Anrdoid studio emulator and Tracking element in Mobile app

Post by odklizec » Wed Mar 18, 2020 10:15 am

Hi,

Could you please try it in spy, without actually running the test? Just open spy as if you created the snapshot and put the xpath there. Does it work then?
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

mmahra
Posts: 37
Joined: Wed Feb 26, 2020 2:17 pm

Re: Anrdoid studio emulator and Tracking element in Mobile app

Post by mmahra » Wed Mar 18, 2020 11:14 am

Hello Pavel,

the Xpath works but indicated the search bar not the returned search.
Last edited by mmahra on Thu Mar 19, 2020 11:08 am, edited 1 time in total.

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

Re: Anrdoid studio emulator and Tracking element in Mobile app

Post by odklizec » Wed Mar 18, 2020 11:28 am

Hi,

Sorry, my mistake :) Here is correct xpath to searched element:
/mobileapp[@title='com.jivesoftware.daily.prodinternal']/form[@title='MainActivity']/androidelement[@rid='content']/androidelement/container[@containertype='Linear']//androidelement[@platformclass='com.jivesoftware.daily.app.components.about.widgets.ContentFollowableItemView']/container//text[@text='myTATSpace']
Basically, the easiest way to find all elements, containing certain string, is to search them from root app element, like this:
/mobileapp[@title='com.jivesoftware.daily.prodinternal']//text[@text='myTATSpace']
This will return all appearances or Texts, containing searched string, in this case 'myTATSpace'. So from all returned elements, you can pick the right one and generate its exact xpath via right click menu >> Update path action.
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

mmahra
Posts: 37
Joined: Wed Feb 26, 2020 2:17 pm

Re: Anrdoid studio emulator and Tracking element in Mobile app

Post by mmahra » Thu Mar 19, 2020 4:31 am

Hi Pavel,

I have been trying to implement your suggestion since yesterday, it is working for text but not for hints, maybe you can suggest a solution for the attached snapshot, I am trying to locate Email address field and Password field and not able to identify caption/text/hint.

Thank you..
Last edited by mmahra on Thu Mar 19, 2020 11:07 am, edited 1 time in total.

mmahra
Posts: 37
Joined: Wed Feb 26, 2020 2:17 pm

Re: Anrdoid studio emulator and Tracking element in Mobile app

Post by mmahra » Thu Mar 19, 2020 6:10 am

Hi again,

I am trying to use variables more often than exact text as it is the main purpose for me here.

I created a variable and gave it a default name and added it in the XPath as per attached text[@text='$BlogName'].

it keeps failing
Last edited by mmahra on Thu Mar 19, 2020 11:07 am, edited 1 time in total.

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

Re: Anrdoid studio emulator and Tracking element in Mobile app

Post by odklizec » Thu Mar 19, 2020 10:14 am

Hi,

I'm afraid that the fields/texts you are looking for are not accessible for Ranorex? I think it would require to adapt the mobile app and move the texts/hints to areas accessible for Ranorex. There is most probably nothing you can do about this on your own.
mmahra wrote:
Thu Mar 19, 2020 4:31 am
I have been trying to implement your suggestion since yesterday, it is working for text but not for hints, maybe you can suggest a solution for the attached snapshot, I am trying to locate Email address field and Password field and not able to identify caption/text/hint.
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

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

Re: Anrdoid studio emulator and Tracking element in Mobile app

Post by odklizec » Thu Mar 19, 2020 10:17 am

Hi,

Variable enclosed in quotes, is no longer considered to be a variable, but simple string. The xpath with variable must be like this:
text[@text=$BlogName]
mmahra wrote:
Thu Mar 19, 2020 6:10 am
Hi again,

I am trying to use variables more often than exact text as it is the main purpose for me here.

I created a variable and gave it a default name and added it in the XPath as per attached text[@text='$BlogName'].

it keeps failing
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

mmahra
Posts: 37
Joined: Wed Feb 26, 2020 2:17 pm

Re: Anrdoid studio emulator and Tracking element in Mobile app

Post by mmahra » Thu Mar 19, 2020 11:05 am

Thanks Pavel

mmahra
Posts: 37
Joined: Wed Feb 26, 2020 2:17 pm

Re: Anrdoid studio emulator and Tracking element in Mobile app

Post by mmahra » Thu Mar 19, 2020 12:03 pm

Unfortunately using,

/mobileapp[@title='com.jivesoftware.daily.prodinternal']/form[@title='ChannelNActivity']/androidelement[@rid='content']/androidelement/androidelement[1]/androidelement[3]/container[@containertype='Linear']/container[@containertype='Frame']/androidelement[1]/androidelement[1]/container[@containertype='Frame']/androidelement[1]/androidelement[1]/androidelement/androidelement[8]/container[@containertype='Linear']/container[2]/androidelement/androidelement/container[2]/container[@containertype='Linear']/text[@text=$BlogName]

Is failing

Failed to find item 'JCMRepository.ComJivesoftwareDailyProdinternal.TestBlog'.
No element found for path '/mobileapp[@title='com.jivesoftware.daily.prodinternal']/form[@title='ChannelNActivity']/androidelement[@rid='content']/androidelement/androidelement[1]/androidelement[3]/container[@containertype='Linear']/container[@containertype='Frame']/androidelement[1]/androidelement[1]/container[@containertype='Frame']/androidelement[1]/androidelement[1]/androidelement/androidelement[8]/container[@containertype='Linear']/container[2]/androidelement/androidelement/container[2]/container[@containertype='Linear']/text[@text='test blog']' at step 'androidelement' after 1116 attempts within 1m.

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

Re: Anrdoid studio emulator and Tracking element in Mobile app

Post by odklizec » Thu Mar 19, 2020 12:25 pm

Hi,

Unfortunately, without seeing the app snapshot, there is nothing I or anyone else here can do or suggest. If the element is not found for given xpath, then the element most probably does not exists or its xpath is different? Please post the snapshot so we can eventually suggest what's wrong. And please, don't forget to create the snapshot exactly at the point, when you are searching for the failed xpath.
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