This document summarizes an Appium webinar presented by Jonathan Lipps on April 24, 2018. It discusses updates to Appium 1.8 including support for the W3C WebDriver spec, app management features, improved screen handling, clipboard support, auxiliary app support, iOS screen recording, iOS performance monitoring, Android log streaming, and Android instant app support. It also covers tips for element locators, using deep links to speed up tests, testing app upgrades, and cross-platform testing best practices.
1. Advanced Appium Tips & Tricks
Jonathan Lipps • Founding Principal • Cloud Grey
@AppiumDevs • @cloudgrey_io • @jlipps • appiumpro.com
Perfecto Mobile Webinar · The Internet
April 24, 2018
7. W3C WebDriver spec support
What’s new in Appium 1.8?
@jlipps · cloudgrey.io
8. W3C WebDriver spec support
App management features
What’s new in Appium 1.8?
@jlipps · cloudgrey.io
9. W3C WebDriver spec support
App management features
Improved screen-related primitives
What’s new in Appium 1.8?
@jlipps · cloudgrey.io
10. W3C WebDriver spec support
App management features
Improved screen-related primitives
Clipboard management features
What’s new in Appium 1.8?
@jlipps · cloudgrey.io
11. W3C WebDriver spec support
App management features
Improved screen-related primitives
Clipboard management features
Auxiliary app support via otherApps capability
What’s new in Appium 1.8?
@jlipps · cloudgrey.io
12. W3C WebDriver spec support
App management features
Improved screen-related primitives
Clipboard management features
Auxiliary app support via otherApps capability
iOS Screen Recording
What’s new in Appium 1.8?
@jlipps · cloudgrey.io
13. W3C WebDriver spec support
App management features
Improved screen-related primitives
Clipboard management features
Auxiliary app support via otherApps capability
iOS Screen Recording
iOS Performance data gathering via Instruments
What’s new in Appium 1.8?
@jlipps · cloudgrey.io
14. W3C WebDriver spec support
App management features
Improved screen-related primitives
Clipboard management features
Auxiliary app support via otherApps capability
iOS Screen Recording
iOS Performance data gathering via Instruments
Android Broadcast device logs for log streaming
What’s new in Appium 1.8?
@jlipps · cloudgrey.io
15. W3C WebDriver spec support
App management features
Improved screen-related primitives
Clipboard management features
Auxiliary app support via otherApps capability
iOS Screen Recording
iOS Performance data gathering via Instruments
Android Broadcast device logs for log streaming
Android Support ‘Instant Apps’
What’s new in Appium 1.8?
@jlipps · cloudgrey.io
16. W3C WebDriver spec support
App management features
Improved screen-related primitives
Clipboard management features
Auxiliary app support via otherApps capability
iOS Screen Recording
iOS Performance data gathering via Instruments
Android Broadcast device logs for log streaming
Android Support ‘Instant Apps’
Many, many bugfixes and performance/stability improvements
What’s new in Appium 1.8?
@jlipps · cloudgrey.io
20. Finding elements with greater speed and stability
Today’s tips: recent selections from appiumpro.com
@jlipps · cloudgrey.io
21. Finding elements with greater speed and stability
Using deep links to speed up tests and reduce flakiness
Today’s tips: recent selections from appiumpro.com
@jlipps · cloudgrey.io
22. Finding elements with greater speed and stability
Using deep links to speed up tests and reduce flakiness
Testing app upgrade scenarios
Today’s tips: recent selections from appiumpro.com
@jlipps · cloudgrey.io
23. Finding elements with greater speed and stability
Using deep links to speed up tests and reduce flakiness
Testing app upgrade scenarios
Cross-platform testing best practices
Today’s tips: recent selections from appiumpro.com
@jlipps · cloudgrey.io
28. Locator Strategy From Support in Appium
class name Selenium Yes
id Selenium Yes
name Selenium Yes
xpath Selenium Yes
accessibility id Appium Yes
-ios predicate string Appium Yes
-ios class chain Appium Yes
-android uiautomator Appium Yes
-ios uiautomation Appium Deprecated
css selector Selenium No
link text Selenium No
partial link text Selenium No
tag name Selenium No
@jlipps · cloudgrey.io
30. It allows for the formulation of complex queries (for example, using the @contains
function)
Why use XPath?
@jlipps · cloudgrey.io
31. It allows for the formulation of complex queries (for example, using the @contains
function)
It can identify any element in the UI hierarchy available to Appium
Why use XPath?
@jlipps · cloudgrey.io
32. It allows for the formulation of complex queries (for example, using the @contains
function)
It can identify any element in the UI hierarchy available to Appium
…
Why use XPath?
@jlipps · cloudgrey.io
33. It allows for the formulation of complex queries (for example, using the @contains
function)
It can identify any element in the UI hierarchy available to Appium
…
that’s about it
Why use XPath?
@jlipps · cloudgrey.io
35. Why not to use XPath
@jlipps · cloudgrey.io
Path-based selectors are brittle
36. Why not to use XPath
@jlipps · cloudgrey.io
Path-based selectors are brittle
It is often expensive to generate an XML representation of the UI
37. Why not to use XPath
@jlipps · cloudgrey.io
Path-based selectors are brittle
It is often expensive to generate an XML representation of the UI
It is often expensive to map XML elements found by XPath to native element objects
38. Why not to use XPath
@jlipps · cloudgrey.io
Path-based selectors are brittle
It is often expensive to generate an XML representation of the UI
It is often expensive to map XML elements found by XPath to native element objects
XPath selectors are not cross-platform
40. Preferred locator strategies
@jlipps · cloudgrey.io
MobileBy.AccessibilityId
Cross-platform locator strategy, will find
elements by Accessibility Id (or Name) on
iOS, and Content Description on Android
41. Preferred locator strategies
@jlipps · cloudgrey.io
MobileBy.AccessibilityId
Cross-platform locator strategy, will find
elements by Accessibility Id (or Name) on
iOS, and Content Description on Android
By.id
Cross-platform locator strategy, will find
elements by Id (and a set of other unique
identifiers) on iOS, and android:id on
Android
43. “Advanced” locator strategies
@jlipps · cloudgrey.io
MobileBy.iOSNsPredicateString
iOS-only locator strategy that allows complex
element lookups based on attributes
44. “Advanced” locator strategies
@jlipps · cloudgrey.io
MobileBy.iOSNsPredicateString
iOS-only locator strategy that allows complex
element lookups based on attributes
MobileBy.iOSClassChain
iOS-only locator strategy that allows complex
element lookups based on attributes and
hierarchy
45. “Advanced” locator strategies
@jlipps · cloudgrey.io
MobileBy.iOSNsPredicateString
iOS-only locator strategy that allows complex
element lookups based on attributes
MobileBy.iOSClassChain
iOS-only locator strategy that allows complex
element lookups based on attributes and
hierarchy
MobileBy.AndroidUIAutomator
Android-only locator strategy that allows use
the UiSelector API to chain element
finding restrictions
46. iOS Predicate String example
@jlipps · cloudgrey.io
MobileBy.iOSNsPredicateString(
"type == 'XCUIElementTypeButton' AND value BEGINSWITH[c] 'foo' AND visible == 1"
);
47. iOS Class Chain example
@jlipps · cloudgrey.io
MobileBy.iOSClassChain(
"**/XCUIElementTypeCell[`name BEGINSWITH “C"`]/XCUIElementTypeButton[10]"
);
54. Android Start the test with custom intents
to navigate directly to the right place
Use intentAction and
optionalIntentArguments parameters
to driver.startActivity
Strategies to set up app state instantly
@jlipps · cloudgrey.io
55. Android Start the test with custom intents
to navigate directly to the right place
Use intentAction and
optionalIntentArguments parameters
to driver.startActivity
iOS Start the app with custom arguments
using Appium capabilities
Use the processArguments capability
when starting a session
Strategies to set up app state instantly
@jlipps · cloudgrey.io
56. Android Start the test with custom intents
to navigate directly to the right place
Use intentAction and
optionalIntentArguments parameters
to driver.startActivity
iOS Start the app with custom arguments
using Appium capabilities
Use the processArguments capability
when starting a session
Cross-platform Use deep linking
Implement a custom url scheme in your app,
then simply use driver.get
Strategies to set up app state instantly
@jlipps · cloudgrey.io
63. Get paths to two versions of your app
App upgrades on Android
@jlipps · cloudgrey.io
64. Get paths to two versions of your app
Start an Appium session using the older version of the app (via the app capability)
App upgrades on Android
@jlipps · cloudgrey.io
65. Get paths to two versions of your app
Start an Appium session using the older version of the app (via the app capability)
Install the new app using driver.installApp
App upgrades on Android
@jlipps · cloudgrey.io
66. Get paths to two versions of your app
Start an Appium session using the older version of the app (via the app capability)
Install the new app using driver.installApp
Trigger the new app to relaunch by using driver.startActivity
App upgrades on Android
@jlipps · cloudgrey.io
69. Get paths to two versions of your app
App upgrades on iOS
@jlipps · cloudgrey.io
70. Get paths to two versions of your app
Start an Appium session using the older version of the app (via the app capability)
App upgrades on iOS
@jlipps · cloudgrey.io
71. Get paths to two versions of your app
Start an Appium session using the older version of the app (via the app capability)
Stop the current app using mobile: terminateApp
App upgrades on iOS
@jlipps · cloudgrey.io
72. Get paths to two versions of your app
Start an Appium session using the older version of the app (via the app capability)
Stop the current app using mobile: terminateApp
Install the new app using mobile: installApp
App upgrades on iOS
@jlipps · cloudgrey.io
73. Get paths to two versions of your app
Start an Appium session using the older version of the app (via the app capability)
Stop the current app using mobile: terminateApp
Install the new app using mobile: installApp
Trigger the new app to relaunch by using mobile: launchApp
App upgrades on iOS
@jlipps · cloudgrey.io
77. Add labels to any element that might be used in testing (i.e., pretty much every
element)
Tips for app development
@jlipps · cloudgrey.io
78. Add labels to any element that might be used in testing (i.e., pretty much every
element)
Add labels as “Accessibility ID” on iOS and “Content Description” on Android—and make
them the same!
Tips for app development
@jlipps · cloudgrey.io
79. Add labels to any element that might be used in testing (i.e., pretty much every
element)
Add labels as “Accessibility ID” on iOS and “Content Description” on Android—and make
them the same!
As much as possible within the product design requirements, keep user flows the same
across apps
Tips for app development
@jlipps · cloudgrey.io
80. Add labels to any element that might be used in testing (i.e., pretty much every
element)
Add labels as “Accessibility ID” on iOS and “Content Description” on Android—and make
them the same!
As much as possible within the product design requirements, keep user flows the same
across apps
Build a test version of your app that has all kinds of state set-up goodies
Tips for app development
@jlipps · cloudgrey.io
81. Add labels to any element that might be used in testing (i.e., pretty much every
element)
Add labels as “Accessibility ID” on iOS and “Content Description” on Android—and make
them the same!
As much as possible within the product design requirements, keep user flows the same
across apps
Build a test version of your app that has all kinds of state set-up goodies
Make debug versions of builds
Tips for app development
@jlipps · cloudgrey.io
82. Add labels to any element that might be used in testing (i.e., pretty much every
element)
Add labels as “Accessibility ID” on iOS and “Content Description” on Android—and make
them the same!
As much as possible within the product design requirements, keep user flows the same
across apps
Build a test version of your app that has all kinds of state set-up goodies
Make debug versions of builds
iOS Use Wildcard App IDs in Provisioning Profiles (so WebDriverAgent can be built
using a custom Bundle ID that works with the profile)
Tips for app development
@jlipps · cloudgrey.io
84. Use a Page Object Model strategy (or similar), to keep differences between platforms
encapsulated
Tips for the testsuite
@jlipps · cloudgrey.io
85. Use a Page Object Model strategy (or similar), to keep differences between platforms
encapsulated
Test step code should be totally platform-agnostic. Only your runner and your object
model should know about platform
Tips for the testsuite
@jlipps · cloudgrey.io
86. Use a Page Object Model strategy (or similar), to keep differences between platforms
encapsulated
Test step code should be totally platform-agnostic. Only your runner and your object
model should know about platform
Avoid XPath in favor of cross-platform locator strategies
Tips for the testsuite
@jlipps · cloudgrey.io
87. Use a Page Object Model strategy (or similar), to keep differences between platforms
encapsulated
Test step code should be totally platform-agnostic. Only your runner and your object
model should know about platform
Avoid XPath in favor of cross-platform locator strategies
Dynamically update test name for reports to include platform name or other details, for
easier debugging
Tips for the testsuite
@jlipps · cloudgrey.io