build mobile application that is easy to automate

14
How to Build a Mobile Application that is Easy to Automate? Jun 2016

Upload: adamcarmi

Post on 08-Jan-2017

88 views

Category:

Software


0 download

TRANSCRIPT

Page 1: Build mobile application that is easy to automate

How to Build a Mobile Application that is Easy to Automate?Jun 2016

Page 2: Build mobile application that is easy to automate

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

Page 3: Build mobile application that is easy to automate

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

Page 4: Build mobile application that is easy to automate

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

Page 5: Build mobile application that is easy to automate

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

Page 6: Build mobile application that is easy to automate

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

Page 7: Build mobile application that is easy to automate

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

Page 8: Build mobile application that is easy to automate

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

Page 9: Build mobile application that is easy to automate

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

Page 10: Build mobile application that is easy to automate

Proprietary UI elements- try to avoid using customized UI elements

UI COMPONENT, LAYOUT AND OTHERS

Page 11: Build mobile application that is easy to automate

Don’t tweak the UI object events.

UI COMPONENT, LAYOUT AND OTHERS

Page 12: Build mobile application that is easy to automate

Avoid using complex layers.

UI COMPONENT, LAYOUT AND OTHERS

Page 13: Build mobile application that is easy to automate

The problem: clicking on an element that is not ready to receive the event

UI Synchronization

Page 14: Build mobile application that is easy to automate

• Provide API on the server side for common operation: (Create User / Account)

• Manage common tests resource

Test configuration