Identifying UI elements in an Android application

Mobile Testing, Android App Testing.
Aloka
Posts: 4
Joined: Fri Feb 26, 2016 12:27 pm

Identifying UI elements in an Android application

Post by Aloka » Wed Apr 27, 2016 1:42 pm

Hi,

Ranorex version: 5.4.5

Problem: Identifying UI elements in an Android application

Description of the problem:
There is a date time picker and the title is the current date and it is changing daily.
Therefore difficult to identify the UI elements.
Is there any solution to detect the UI element?

Example code:
form[@title=’ Wed, Apr 27, 2016’]/container[@rid='content']//button[@rid='button1']

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

Re: Identifying UI elements in an Android application

Post by odklizec » Wed Apr 27, 2016 2:29 pm

Hi,

Sure, you can overcome this problem by replacing the hardcoded date string with module variable and then fill that variable with actual date (via custom code).
So the xpath should look like this:

Code: Select all

form[@title=$date]/container[@rid='content']//button[@rid='button1']
Now the user code you need to run before accessing the above xpath should look like this:

Code: Select all

string dateFormat = " ddd, MMM dd, yyyy";  // date format like this: Wed, Apr 27, 2016
System.DateTime actualDate = System.DateTime.Today;  //get actual date  
date = returnDate.ToString(dateFormat); //convert obtained date to string
Where 'date' variable is the one defined in the module variable.
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

Aloka
Posts: 4
Joined: Fri Feb 26, 2016 12:27 pm

Re: Identifying UI elements in an Android application

Post by Aloka » Tue May 03, 2016 5:43 am

Than you. I'll try the solution.