Automate Legacy-System Testing: Easy, Reliable, and Extendible
Build mobile application that is easy to automate
Transcript of Build mobile application that is easy to automate
How to Build a Mobile Application that is Easy to Automate?Jun 2016
HOW TO BUILD A MOBILE APPLICATION THAT IS EASY TO AUTOMATE?
Select Technology Object identification background and challenges Xpath / Indexs Properties and considerations in Object identification Application navigation UI component, Layout and Others, Synchronization
The technology you use has a big impact on the automation process. Using common technology removes risks.
There are 3 types of UI objects:• Native objects – using the OS native objects. The native objects can be
created directly or using some kind of framework (like Xamarin).• Web objects- run inside WebView (like Phonegap)• Proprietary objects- new set of UI elements (like Adobe Flash)
Avoid technologies that are not model based
TRY TO AVOID THIS OPTION
SELECTED TECHNOLOGY
The main challenge in mobile automation is identifying UI elements.• Automation tool sees UI as tree of nodes• One element can contain other elements• Every node has properties• Common properties: text, id, hint, accessibility label, placeholder
A query needs to be created in order to identify an element.
CHALLENGE #1: OBJECT IDENTIFICATION
Syntax:Xpath=//*[@text=‘OK’]//- scan the UI tree from the root.*- find any node (don’t care about the node name)[]- that (condition)@- the property (in this case text)
Xpath is a very common technology for identifying UI objects.
XPath
Index
What if we have more than one element that match the quarry?
• The tool will usually will select the first element in the UI
(in some tools it will be visual order, other tools will use node hierarchy order).
• Relaying your identification on index is not a good sign for your automation robastness
Things to consider when using properties to identify objects:• Property visibility – text / placeholder is visible to the user• Uniqueness – id is unique for web• Multilingual support• Multi-platform – text / class / placeholder …• Not dynamic• Easy to query• Fast to query – isVisable sometime can be slow to query
CONSIDERATIONS IN OBJECT IDENTIFICATION
Field name OS Pros. Cons.AccessibilityIdentif
y/ ContentDescriptio
nAndroid/iOS
Usually unique Not dynamic Support multi lingual
Needs development attention / awareness
Id Web Unique Fast to query
In some technologies it is auto generated and can change in new versions
Id Android Very command Effortless Multilingual Not Unique
Hint/Placeholder Android/iOS Visible Effortless Does not change with
the field content Inapplicable for multi lingual apps
Class Android/iOS Effortless Will probably require index
AccessibilityLabel iOS Effortless Good option for
images Dynamic with the text Inapplicable for multi lingual apps
Text Android/iOS/Web
Visible Unique in many cases Effortless
Can be dynamic Inapplicable for multi lingual apps
CONSIDERATIONS IN OBJECT IDENTIFICATION
For Automation to be successful the operation that is build should be stateless. Try to avoid unnecessary state full operations.
Stateless = executes any operation regardless of current state/page• Example for a stateless operation: top menu button• Example for a state-full operation: login process, first user flow
APPLICATION NAVIGATION SHOULD BE EASY
Proprietary UI elements- try to avoid using customized UI elements
UI COMPONENT, LAYOUT AND OTHERS
Don’t tweak the UI object events.
UI COMPONENT, LAYOUT AND OTHERS
Avoid using complex layers.
UI COMPONENT, LAYOUT AND OTHERS
The problem: clicking on an element that is not ready to receive the event
UI Synchronization
• Provide API on the server side for common operation: (Create User / Account)
• Manage common tests resource
Test configuration