one test to rule them all - conquer android and ios with one script
TRANSCRIPT
ONE TEST TO RULE THEM ALL - CONQUER ANDROID AND IOS WITH ONE SCRIPTEYAL YOVEL, SOLUTION ARCHITECT QUALITEST GROUP
AUGUST 29, 2017
ASAF SAAR, MOBILE PRODUCT MANAGEMENT DIRECTOR, SAUCE LABS
AUGUST 29, 2017
EYAL YOVEL, SOLUTION ARCHITECT QUALITESTGROUP
ASAF SAAR, MOBILE PRODUCT MANAGEMENT
DIRECTOR, SAUCE LABS
MOBILE TESTING STRATEGY
Mobile App TestingWeb Testing
The industry’s only cloud-based testing platform for both web and mobile applications that spans desktops,
simulators, emulators and real devices
Desktops Emulators & Simulators Real Devices
MOBILE FIRST AT SCALE
By 2022, 70% of software interactions in enterprises will occur on mobile devices.
MarketGuideforMobileApplicationTestingServicesSusanneMatson(June2017)
CURRENT MOBILE OFFERING
Manual Testing
Automated Testing
Emulators & Simulators
Public Cloud Private Cloud
Real Devices
Public Cloud
Mobile Testing
SECURITY & PRIVACY
GARTNER SUPPORTS OUR APPROACH
A recommended approach is to find a healthy mix of emulators, simulators and real devices to get the best out of your test automation.
MarketGuideforMobileAppTestAutomationToolsMaritessSobejana(April2016)
COMPREHENSIVE MOBILE TESTING
Device Testing (on Wi-FiNetworks + Networks
Simulation Tools)
● Recommended only for small subset of network-dependent use cases
● Use for stable features● Distribute features across device models and form factors● Important for UX Testing● Combine with WANem or similar tools for simulating
network connectivity conditions
● High volume functional tests for large integration builds● Frequent builds with high concurrency to reduce build times,
enabling dev teams to not block each other
Device Testing
(in network)
Device Testing (on Wi-FiNetworks + Networks
Simulation Tools)
Emulator&Simulator Testing
EMULATORS, SIMULATORS & REAL DEVICES COVER ALL USE CASES
THE CHALLENGES FACED BY QA
THE CHALLENGES FACED BY QA
AUGUST 29, 2017 © Sauce Labs, Inc. 10
Appiumisanopensourcetoolforautomatingnative,mobileweband
hybridapplicationsoniOSandAndroidplatforms
THE CHALLENGES FACED BY QA
AUGUST 29, 2017 © Sauce Labs, Inc. 11
THE CHALLENGES FACED BY QA
AUGUST 29, 2017 © Sauce Labs, Inc. 12
HowtospeedupwritingtestsusingtheSerenityBDDFrameworkandthePageObjectModel
Challengesandsolutionsfordevelopingacross-platformmobiletestingsolution
Howtodefineandimplementamobiletestingstrategy
PAGE OBJECT MODEL
WHAT IS A PAGE OBJECT MODEL
AUGUST 29, 2017
• Modelling UI components as objects to be consumed by test code
• Representation of the services offered by a page
• Abstracts test logic away from interaction with the WebDriver API and System-Under-Test
© Sauce Labs, Inc. 14
WHY PAGE OBJECT MODEL
AUGUST 29, 2017
• Expose page and component services rather than mechanics
• Write concise tests that exercise functionality, not technical details
• Create maintainable tests by isolating the effect of UI change on test code
• Produce readable tests by keeping implementation details out of test code.
© Sauce Labs, Inc. 15
AUGUST 29, 2017
• Tests are comprised of steps
• Steps interact with pages• Pages provide services and key components• Operations on pages occur without any knowledge
of page structure
• Pages are comprised of elements
• Each element represents a single item on a page that can be interacted with• Text, buttons, fields, images, etc.
LAYERS OF ABSTRACTION
© Sauce Labs, Inc. 16
Steps
PageObjects
Elements
Tests
INTRODUCING
AUGUST 29, 2017
• Demonstrating the Page Object Model requires a testing framework
• Serenity is an open source Java (and recently JavaScript) library to speed up writing tests; including:• Complete WebDriver testing framework• Parallel execution of tests using JUnit, Cucumber or JBehave• Integration with Sauce Labs, Appium, JIRA, and other testing tools• Detailed reporting
• Well used across the industry.
© Sauce Labs, Inc. 18
ABOUT THE DEMO ENVIRONMENT
THE SYSTEM UNDER TEST
AUGUST 29, 2017 © Sauce Labs, Inc. 20
My giffgaff App – A UK mobile network
AUGUST 29, 2017
Introducing a basic Serenity test
Scenario: Log in to the giffgaff App
Given I am not logged inWhen I log in as ‘eyalyovel’Then I am logged in as ‘eyalyovel’
Framework:• Serenity, Appium, BDD (feature file) and Maven• Execute on local Samsung galaxy S6 device and on
iPhone 7 simulator located on the Sauce Labs cloud • Hard-coded test data
LOGIN TEST
© Sauce Labs, Inc. 21
StepsLoginSteps
PageObjectsLoginPage
MygiffgaffAccountPage
ElementsusernameFieldpasswordFieldloginButton
TestLogin.feature
AUGUST 29, 2017
DEMO THE FRAMEWORK
© Sauce Labs, Inc. 22
CHALLENGES AND SOLUTIONS FOR DEVELOPING A CROSS-PLATFORM
MOBILE TESTING SOLUTION
FIND ELEMENTS IN ANDROID AND IOS
AUGUST 29, 2017
IN MOST CASES WE WILL NOT BE ABLE TO FIND AN ELEMENT USING THE SAME IDENTIFIER IN ANDROID AND IOS
© Sauce Labs, Inc. 24
FIND ELEMENTS IN ANDROID AND IOS
AUGUST 29, 2017
IN MOST CASES WE WILL NOT BE ABLE TO FIND AN ELEMENT USING THE SAME IDENTIFIER IN ANDROID AND IOS
© Sauce Labs, Inc. 25
DIFFERENCES IN BEHAVIOR
AUGUST 29, 2017
DIFFERENCES IN BEHAVIOR BETWEEN THE PLATFORMS
FOR EXAMPLE: FIND THE MEMBER NAME:
© Sauce Labs, Inc. 26
DIFFERENCES IN BEHAVIOR
AUGUST 29, 2017
DIFFERENCES IN BEHAVIOR BETWEEN THE PLATFORMS
FOR EXAMPLE: FIND THE MEMBER NAME:
© Sauce Labs, Inc. 27
SOLUTION FOR FIND ELEMENTS
AUGUST 29, 2017
USE THE ANNOTATIONS @ANDROIDFINDBY AND @IOSFINDBY
© Sauce Labs, Inc. 28
SOLUTION FOR DIFFERENCES IN BEHAVIOR
AUGUST 29, 2017
WE WILL NEED DIFFERENT STEPS/CODE FOR THE DIFFERENT PLATFORMS FOR EXECUTING THE SAME SCENARIO.
© Sauce Labs, Inc. 29
• We can have different page object files for the Android and the iOS pages
• Before running the tests, find what is the platform and run the code according to that
AUGUST 29, 2017
DEMO RUN ON ANDROID PLATFORM
© Sauce Labs, Inc. 30
AUGUST 29, 2017
DEMO RUN ON IOS PLATFORM
© Sauce Labs, Inc. 31
LET’S DO THIS.