SlideShare a Scribd company logo
1 of 41
Download to read offline
Continuous mobile automation
with Appium in real device
cloud
MoT Berlin @ SauceLabs
hello!
I am Dmitry
Sr. QA Automation Engineer @
2
automateMeNow dmle
It’s not about:
✘ Appium vs Espresso / XCUITest
✘ Real devices vs emulators
✘ Sauce Labs vs other cloud providers
3
But:
✘ Get familiar with potential challenges
✘ Minimize test flakiness and get the most out of Appium
✘ Stabilize test execution in real device cloud
What works for me…
4
May not work for everyone
1.
Let’s start with basics
2 + 2 = 4
5
Keep in mind while using Appium
✘ Install app only once
6
✘ Stop using bad locators
✘ Implicit wait = sleep = bad practice
✘ Every appium call counts
✘ Take care of keyboard
✘ Use API to generate test data / change app status
✘ Start activity / relaunch app / deep links between tests
Fast tests = Avoid using XPath
Fast & reliable locators
✘ id
✘ Accessibility id
✘ Predicate string
7
“- Don’t you ever use XPath?
8
XPath of total locators (~200):
Android: 6%
iOS: 4%
- I do. Only when really necessary
9
Starting using device cloud like...
Source: http://en.espn.co.uk/f1/motorsport/image/6007.html
10
After 3-4 sessions...
Source: https://insurance4motorsport.blogspot.com/2013/08/formula-one-driver-insurance.html
2.
Local vs cloud
11
Be careful with version you use
12
appium-base-driver@3.12.0
appium-xcuitest-driver@2.102.0
appium-xcode@3.7.2
WebDriverAgent
appium-ios-driver@2.13.0
… 40+ modules
java-client@6.1.0
python-client@0.31
ruby-lib@9.16.0
wd@1.11.0
webdriverio@4.14.0
Server Client
Cloud is black box
13
appium-base-driver@3.12.0
appium-xcuitest-driver@2.102.0
appium-xcode@3.7.2
WebDriverAgent
appium-ios-driver@2.13.0
… 40+ modules
java-client@6.1.0
python-client@0.31
ruby-lib@9.16.0
wd@1.11.0
webdriverio@4.14.0
Server Client
In Cloud only release version:
1.9.1
1.8.1
1.8.0
1.7.2
3.
Device selection
14
Devices have different:
15
✘ OS version
✘ Manufacture customized OS
✘ DPI / Screen resolution
✘ CPU / RAM
✘ Default connectivity type
✘ Keyboard
✘ Preinstalled apps
findElementById(“highlights”)
Samsung Galaxy S9
Motorola Moto G4
16Source: https://play.google.com/store/apps/details?id=in.olx.cashmycar.dealer
“app_india”: [
“Huawei_Mate_Pro_real”,
“HUAWEI_P20_real”,
“Samsung_Galaxy_S9_real”,
“Samsung_Galaxy_S8_Plus_real”
“LG_G7_Thinq_real”,
“OnePlus_6_real”,
“ASUS_Zenfone_5_real”
]
Use device matrix
17
✘ Based on users / local market stats
✘ Different manufactures / OS versions
1. Stabilize tests for matrix
2. Remove unreliable devices
3. Sync matrix every 3+ months
4. Keep it carefully from growth
Define device for test run
API:
/available
18
Filter
matrix
Select
random
Start
session
Dynamic allocation
filter by OS version & device type
static
UI Automator
Search for hidden elements inside scrollable View
findElementByUIAutomator(“new UiScrollable(new UiSelector()...”)
19
4.
Connectivity Type
20
Check connection on session start
Keep in mind:
✘ Airplane Mode: 6+
✘ Data connection: <=4.4
✘ Wi-Fi connection: all versions
21
✘ getNetworkConnection()
✘ setNetworkConnection()
Network Connection (Android only)
22
Value Data Wifi Airplane Mode
0 (None) 0 0 0
1 (Airplane) 0 0 1
2 (Wifi only) 0 1 0
4 (Data on) 1 0 0
6 (All on) 1 1 0
5.
Localisation
23
Check language on session start
✘ Check the element text on login
✘ Change via switch button
In worst case
✘ Skip tests with localisation checks
24
6.
Device allocation
25
Once in a while getting exception
UnknownError - An unknown
server-side error occurred
while processing the
command. Selenium error: Lost
contact with app, please check
Appium log for more
information
The environment you
requested was unavailable.
Unable to install app to the
device XXX.
Unable to allocate device YYY
within 900000ms or 3 tries.
This can happen if there were
no available devices within the
time or your plan's max
concurrent test run is not
corresponding to your usage
26
27
Smart device allocation
Source: http://en.espn.co.uk/f1/motorsport/image/6007.html
3 iterations of custom mechanism
Version 1
Pull device matrix
Get available devices via API
Filter matrix with available
Select random one for session
Dynamic allocation
Version 2
Run v1 for EU device cluster
Run v1 for US device cluster
Dynamic allocation
Version 3
Run v2
Catch session creation error
Add device to “black list”
Retry v2 with black list filter
28
Device allocation handling
Select
Device
29
Allocate
Device
Done
Failed
Add device to Blacklist.
Retry
7.
Appium session
30
“- Run each test separately
31
- It takes too long
- Use device caching
- Still too long
Session start ~ 40 sec
IOS ~ 70 sec
Running suite of 30 tests
32
Cached restart ~ 18 sec
IOS ~ 25 sec
33
Session restart timeout
Source: https://www.mclaren.com/formula1/heritage/bruce-mclaren/
Custom sesion restart timeout
1. Define own session restart timeout (5 - 7 min)
2. Start session with time counter and enabled device caching
3. Starting from 2nd test check timeout - counter > max_test_time
4. Restart session before N test when timeout reached
5. Save result in SL, get report link, continue execution
34
Appium session handling
New
session
35
Close current session & start new with cached device
Test 1
Check
session
time
Test N
Retry
30 tests ~ 13 min
Session timeout of 7 min, 1 restart
39%Time saved!
28 restarts ~ 8.4 min
18 sec / restart
36
Useful resources:
37
✘ http://appium.io/docs/en/about-appium/intro
✘ https://appiumpro.com
✘ https://wiki.saucelabs.com/display/DOCS
✘ https://stackoverflow.com/search?q=appium
Make Appium a better tool
Follow the progress:
Image comparison:
https://github.com/appium/appium/blob/
master/docs/en/writing-running-appium/
image-comparison.md
Element find plugins:
https://github.com/appium/appium/blob/
master/docs/en/advanced-concepts/ele
ment-finding-plugins.md
Contribute:
✘ Create issues
✘ Add/translate docs
✘ Answer questions
✘ Add new functionality
✘ Support client libraries
38
Let’s summarize:
39
✘ Follow the best practices with Appium
✘ Don’t try to support tests for all the devices in cloud
✘ Make sure to set correct connection and language on device
✘ Don’t fully rely on cloud with device allocation
✘ Be critical to test time execution, try to improve
40
Back on track!
Source: https://www.juniqe.com/formula-1-poster-alu-frame-3445779.html
thanks!
Any questions?
You can find me at
41
automateMeNow dmle

More Related Content

Similar to Continuous mobile automation with Appium in Real Device Cloud

How to kill test flake in appium
How to kill test flake in appiumHow to kill test flake in appium
How to kill test flake in appiumGaurav Singh
 
LDNSE: Testdroid for Mobile App and Web Testing (London Selenium Meetup)
LDNSE: Testdroid for Mobile App and Web Testing (London Selenium Meetup)LDNSE: Testdroid for Mobile App and Web Testing (London Selenium Meetup)
LDNSE: Testdroid for Mobile App and Web Testing (London Selenium Meetup)Bitbar
 
Aikau testing tech talk live 83 20150204
Aikau testing tech talk live 83 20150204Aikau testing tech talk live 83 20150204
Aikau testing tech talk live 83 20150204David Webster
 
Selenium Camp 2016 - Kiev, Ukraine
Selenium Camp 2016 -  Kiev, UkraineSelenium Camp 2016 -  Kiev, Ukraine
Selenium Camp 2016 - Kiev, UkraineJustin Ison
 
JaSST'18 Hokkaido Improve Automation Testing
JaSST'18 Hokkaido Improve Automation TestingJaSST'18 Hokkaido Improve Automation Testing
JaSST'18 Hokkaido Improve Automation TestingSadaaki Emura
 
ScalaUA - distage: Staged Dependency Injection
ScalaUA - distage: Staged Dependency InjectionScalaUA - distage: Staged Dependency Injection
ScalaUA - distage: Staged Dependency Injection7mind
 
Selenium Israel Meetup
Selenium Israel MeetupSelenium Israel Meetup
Selenium Israel MeetupJustin Ison
 
Building an advanced automation solution based on Appium
Building an advanced automation solution based on AppiumBuilding an advanced automation solution based on Appium
Building an advanced automation solution based on AppiumAnton Sirota
 
Test automation engineer
Test automation engineerTest automation engineer
Test automation engineerSadaaki Emura
 
Unit Testing Lightning Components with Jasmine
Unit Testing Lightning Components with JasmineUnit Testing Lightning Components with Jasmine
Unit Testing Lightning Components with JasmineKeir Bowden
 
Alexey Ostapov: Distributed Video Management and Security Systems: Tips and T...
Alexey Ostapov: Distributed Video Management and Security Systems: Tips and T...Alexey Ostapov: Distributed Video Management and Security Systems: Tips and T...
Alexey Ostapov: Distributed Video Management and Security Systems: Tips and T...Andriy Krayniy
 
Remote iOS Devices Server – Scaling iOS
Remote iOS Devices Server – Scaling iOSRemote iOS Devices Server – Scaling iOS
Remote iOS Devices Server – Scaling iOSNick Abalov
 
QA Best Practices
QA  Best PracticesQA  Best Practices
QA Best PracticesJames York
 
Taishaun_OwnensCNS-533_Lab
Taishaun_OwnensCNS-533_LabTaishaun_OwnensCNS-533_Lab
Taishaun_OwnensCNS-533_LabTaishaun Owens
 
Android Mobile Application Testing: Specific Functional, Performance, Device ...
Android Mobile Application Testing: Specific Functional, Performance, Device ...Android Mobile Application Testing: Specific Functional, Performance, Device ...
Android Mobile Application Testing: Specific Functional, Performance, Device ...SoftServe
 
Mobile Saturday. Тема 2. Особенности тестирования приложения на Android: Spec...
Mobile Saturday. Тема 2. Особенности тестирования приложения на Android: Spec...Mobile Saturday. Тема 2. Особенности тестирования приложения на Android: Spec...
Mobile Saturday. Тема 2. Особенности тестирования приложения на Android: Spec...GoIT
 
Intro to Automation Using Perfecto's CQ Lab
Intro to Automation Using Perfecto's CQ LabIntro to Automation Using Perfecto's CQ Lab
Intro to Automation Using Perfecto's CQ LabLizzy Guido (she/her)
 

Similar to Continuous mobile automation with Appium in Real Device Cloud (20)

Winrunner
WinrunnerWinrunner
Winrunner
 
How to kill test flake in appium
How to kill test flake in appiumHow to kill test flake in appium
How to kill test flake in appium
 
LDNSE: Testdroid for Mobile App and Web Testing (London Selenium Meetup)
LDNSE: Testdroid for Mobile App and Web Testing (London Selenium Meetup)LDNSE: Testdroid for Mobile App and Web Testing (London Selenium Meetup)
LDNSE: Testdroid for Mobile App and Web Testing (London Selenium Meetup)
 
Aikau testing tech talk live 83 20150204
Aikau testing tech talk live 83 20150204Aikau testing tech talk live 83 20150204
Aikau testing tech talk live 83 20150204
 
Selenium Camp 2016 - Kiev, Ukraine
Selenium Camp 2016 -  Kiev, UkraineSelenium Camp 2016 -  Kiev, Ukraine
Selenium Camp 2016 - Kiev, Ukraine
 
JaSST'18 Hokkaido Improve Automation Testing
JaSST'18 Hokkaido Improve Automation TestingJaSST'18 Hokkaido Improve Automation Testing
JaSST'18 Hokkaido Improve Automation Testing
 
ScalaUA - distage: Staged Dependency Injection
ScalaUA - distage: Staged Dependency InjectionScalaUA - distage: Staged Dependency Injection
ScalaUA - distage: Staged Dependency Injection
 
Selenium Israel Meetup
Selenium Israel MeetupSelenium Israel Meetup
Selenium Israel Meetup
 
Building an advanced automation solution based on Appium
Building an advanced automation solution based on AppiumBuilding an advanced automation solution based on Appium
Building an advanced automation solution based on Appium
 
Run & Report
Run & ReportRun & Report
Run & Report
 
Unit Testing in Android
Unit Testing in AndroidUnit Testing in Android
Unit Testing in Android
 
Test automation engineer
Test automation engineerTest automation engineer
Test automation engineer
 
Unit Testing Lightning Components with Jasmine
Unit Testing Lightning Components with JasmineUnit Testing Lightning Components with Jasmine
Unit Testing Lightning Components with Jasmine
 
Alexey Ostapov: Distributed Video Management and Security Systems: Tips and T...
Alexey Ostapov: Distributed Video Management and Security Systems: Tips and T...Alexey Ostapov: Distributed Video Management and Security Systems: Tips and T...
Alexey Ostapov: Distributed Video Management and Security Systems: Tips and T...
 
Remote iOS Devices Server – Scaling iOS
Remote iOS Devices Server – Scaling iOSRemote iOS Devices Server – Scaling iOS
Remote iOS Devices Server – Scaling iOS
 
QA Best Practices
QA  Best PracticesQA  Best Practices
QA Best Practices
 
Taishaun_OwnensCNS-533_Lab
Taishaun_OwnensCNS-533_LabTaishaun_OwnensCNS-533_Lab
Taishaun_OwnensCNS-533_Lab
 
Android Mobile Application Testing: Specific Functional, Performance, Device ...
Android Mobile Application Testing: Specific Functional, Performance, Device ...Android Mobile Application Testing: Specific Functional, Performance, Device ...
Android Mobile Application Testing: Specific Functional, Performance, Device ...
 
Mobile Saturday. Тема 2. Особенности тестирования приложения на Android: Spec...
Mobile Saturday. Тема 2. Особенности тестирования приложения на Android: Spec...Mobile Saturday. Тема 2. Особенности тестирования приложения на Android: Spec...
Mobile Saturday. Тема 2. Особенности тестирования приложения на Android: Spec...
 
Intro to Automation Using Perfecto's CQ Lab
Intro to Automation Using Perfecto's CQ LabIntro to Automation Using Perfecto's CQ Lab
Intro to Automation Using Perfecto's CQ Lab
 

Recently uploaded

Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Angeliki Cooney
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Zilliz
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Jeffrey Haguewood
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusZilliz
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKJago de Vreede
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesrafiqahmad00786416
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...apidays
 
Cyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfCyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfOverkill Security
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDropbox
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024The Digital Insurer
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native ApplicationsWSO2
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxRustici Software
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 

Recently uploaded (20)

Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
Cyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfCyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdf
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 

Continuous mobile automation with Appium in Real Device Cloud

  • 1. Continuous mobile automation with Appium in real device cloud MoT Berlin @ SauceLabs
  • 2. hello! I am Dmitry Sr. QA Automation Engineer @ 2 automateMeNow dmle
  • 3. It’s not about: ✘ Appium vs Espresso / XCUITest ✘ Real devices vs emulators ✘ Sauce Labs vs other cloud providers 3 But: ✘ Get familiar with potential challenges ✘ Minimize test flakiness and get the most out of Appium ✘ Stabilize test execution in real device cloud
  • 4. What works for me… 4 May not work for everyone
  • 5. 1. Let’s start with basics 2 + 2 = 4 5
  • 6. Keep in mind while using Appium ✘ Install app only once 6 ✘ Stop using bad locators ✘ Implicit wait = sleep = bad practice ✘ Every appium call counts ✘ Take care of keyboard ✘ Use API to generate test data / change app status ✘ Start activity / relaunch app / deep links between tests
  • 7. Fast tests = Avoid using XPath Fast & reliable locators ✘ id ✘ Accessibility id ✘ Predicate string 7
  • 8. “- Don’t you ever use XPath? 8 XPath of total locators (~200): Android: 6% iOS: 4% - I do. Only when really necessary
  • 9. 9 Starting using device cloud like... Source: http://en.espn.co.uk/f1/motorsport/image/6007.html
  • 10. 10 After 3-4 sessions... Source: https://insurance4motorsport.blogspot.com/2013/08/formula-one-driver-insurance.html
  • 12. Be careful with version you use 12 appium-base-driver@3.12.0 appium-xcuitest-driver@2.102.0 appium-xcode@3.7.2 WebDriverAgent appium-ios-driver@2.13.0 … 40+ modules java-client@6.1.0 python-client@0.31 ruby-lib@9.16.0 wd@1.11.0 webdriverio@4.14.0 Server Client
  • 13. Cloud is black box 13 appium-base-driver@3.12.0 appium-xcuitest-driver@2.102.0 appium-xcode@3.7.2 WebDriverAgent appium-ios-driver@2.13.0 … 40+ modules java-client@6.1.0 python-client@0.31 ruby-lib@9.16.0 wd@1.11.0 webdriverio@4.14.0 Server Client In Cloud only release version: 1.9.1 1.8.1 1.8.0 1.7.2
  • 15. Devices have different: 15 ✘ OS version ✘ Manufacture customized OS ✘ DPI / Screen resolution ✘ CPU / RAM ✘ Default connectivity type ✘ Keyboard ✘ Preinstalled apps
  • 16. findElementById(“highlights”) Samsung Galaxy S9 Motorola Moto G4 16Source: https://play.google.com/store/apps/details?id=in.olx.cashmycar.dealer
  • 17. “app_india”: [ “Huawei_Mate_Pro_real”, “HUAWEI_P20_real”, “Samsung_Galaxy_S9_real”, “Samsung_Galaxy_S8_Plus_real” “LG_G7_Thinq_real”, “OnePlus_6_real”, “ASUS_Zenfone_5_real” ] Use device matrix 17 ✘ Based on users / local market stats ✘ Different manufactures / OS versions 1. Stabilize tests for matrix 2. Remove unreliable devices 3. Sync matrix every 3+ months 4. Keep it carefully from growth
  • 18. Define device for test run API: /available 18 Filter matrix Select random Start session Dynamic allocation filter by OS version & device type static
  • 19. UI Automator Search for hidden elements inside scrollable View findElementByUIAutomator(“new UiScrollable(new UiSelector()...”) 19
  • 21. Check connection on session start Keep in mind: ✘ Airplane Mode: 6+ ✘ Data connection: <=4.4 ✘ Wi-Fi connection: all versions 21 ✘ getNetworkConnection() ✘ setNetworkConnection()
  • 22. Network Connection (Android only) 22 Value Data Wifi Airplane Mode 0 (None) 0 0 0 1 (Airplane) 0 0 1 2 (Wifi only) 0 1 0 4 (Data on) 1 0 0 6 (All on) 1 1 0
  • 24. Check language on session start ✘ Check the element text on login ✘ Change via switch button In worst case ✘ Skip tests with localisation checks 24
  • 26. Once in a while getting exception UnknownError - An unknown server-side error occurred while processing the command. Selenium error: Lost contact with app, please check Appium log for more information The environment you requested was unavailable. Unable to install app to the device XXX. Unable to allocate device YYY within 900000ms or 3 tries. This can happen if there were no available devices within the time or your plan's max concurrent test run is not corresponding to your usage 26
  • 27. 27 Smart device allocation Source: http://en.espn.co.uk/f1/motorsport/image/6007.html
  • 28. 3 iterations of custom mechanism Version 1 Pull device matrix Get available devices via API Filter matrix with available Select random one for session Dynamic allocation Version 2 Run v1 for EU device cluster Run v1 for US device cluster Dynamic allocation Version 3 Run v2 Catch session creation error Add device to “black list” Retry v2 with black list filter 28
  • 31. “- Run each test separately 31 - It takes too long - Use device caching - Still too long
  • 32. Session start ~ 40 sec IOS ~ 70 sec Running suite of 30 tests 32 Cached restart ~ 18 sec IOS ~ 25 sec
  • 33. 33 Session restart timeout Source: https://www.mclaren.com/formula1/heritage/bruce-mclaren/
  • 34. Custom sesion restart timeout 1. Define own session restart timeout (5 - 7 min) 2. Start session with time counter and enabled device caching 3. Starting from 2nd test check timeout - counter > max_test_time 4. Restart session before N test when timeout reached 5. Save result in SL, get report link, continue execution 34
  • 35. Appium session handling New session 35 Close current session & start new with cached device Test 1 Check session time Test N Retry
  • 36. 30 tests ~ 13 min Session timeout of 7 min, 1 restart 39%Time saved! 28 restarts ~ 8.4 min 18 sec / restart 36
  • 37. Useful resources: 37 ✘ http://appium.io/docs/en/about-appium/intro ✘ https://appiumpro.com ✘ https://wiki.saucelabs.com/display/DOCS ✘ https://stackoverflow.com/search?q=appium
  • 38. Make Appium a better tool Follow the progress: Image comparison: https://github.com/appium/appium/blob/ master/docs/en/writing-running-appium/ image-comparison.md Element find plugins: https://github.com/appium/appium/blob/ master/docs/en/advanced-concepts/ele ment-finding-plugins.md Contribute: ✘ Create issues ✘ Add/translate docs ✘ Answer questions ✘ Add new functionality ✘ Support client libraries 38
  • 39. Let’s summarize: 39 ✘ Follow the best practices with Appium ✘ Don’t try to support tests for all the devices in cloud ✘ Make sure to set correct connection and language on device ✘ Don’t fully rely on cloud with device allocation ✘ Be critical to test time execution, try to improve
  • 40. 40 Back on track! Source: https://www.juniqe.com/formula-1-poster-alu-frame-3445779.html
  • 41. thanks! Any questions? You can find me at 41 automateMeNow dmle