Automation of mobile testing: Basics of Mobile Cloud Services

Содержание

Слайд 2

Basic tools How to write auto-tests for mobile apps Basics of

Basic tools
How to write auto-tests for mobile apps
Basics of Mobile Cloud

Services
Tips and tricks

Plan

Слайд 3

Cloud services of mobile devices (mobile farms) are the modern approach.

Cloud services of mobile devices (mobile farms) are the modern approach. 
They provide

developers and testers with remote access to sets of physical devices for fixed prices and some tools for using them
Remote access to set of emulators can be provided as well for less prices

Mobile Clouds

форм-фактор

Слайд 4

Utilize advantages, avoid weaknesses (of real devices and emulators): Doesn’t take

Utilize advantages, avoid weaknesses (of real devices and emulators):
Doesn’t take space

on your desk
No power needs
A range of devices of different capabilities
Do not need to take care about devices
Pay for access only, no Total Cost of Ownership

Advantages

Слайд 5

Not a fairy tale: the set of models is defined by

Not a fairy tale:
the set of models is defined by

provider of mobile cloud
availability of items
communications could be a problem:
connection could be lost
devices react with a delay

Problems

Слайд 6

Public mobile test clouds: SauceLabs, Browserstack EPAM own mobile cloud solution

Public mobile test clouds: SauceLabs, Browserstack
EPAM own mobile cloud solution (now

located in Minsk and SPb)
Free access for EPAM employees by their credentials
Sites of this cloud can be located at any of EPAM offices

Examples

Слайд 7

Located here Access: by EPAM account for all employee Features: Physical

Located here
Access: by EPAM account for all employee
Features:
Physical Android and

iOS devices (up to 25 of each type)
Inspector.
Use your desktop Chrome for debugging remote devices
Appium support
CI integration
Some device can be reserved for a certain time
REST interface for booking and application setup
How to start working?

EPAM mobile cloud

Слайд 8

Install security certificates to Java SDK Get a token and integrate

Install security certificates to Java SDK
Get a token and integrate it

to Appium driver URL
Check driver type and change it if required
Select a certain device (Android or iOS?)
Build, run, …
Enjoy?????

Modify our tests for m-cloud

Слайд 9

This token gives you access to REST API and Appium Automation

This token gives you access to REST API and Appium Automation
Open

your account -> User Setting
Click " + ", select EPM-TSTF Project and click "Get Access Token“. If you has an expired key, you need remove it before (use red REMOVE link at the right)
Write down the key value and keep it safe
This access token is used for both REST API and Appium connection
TTL of this token is 1 month

Get a token

Слайд 10

Change Appium server URL org.apache.maven.plugins maven-surefire-plugin 2.22.2 ${suite.file} http://localhost:4723/wd/hub https://EPM-TSTF:${token}@mobilecloud.epam.com/wd/hub org.apache.maven.plugins maven-compiler-plugin 1.8 1.8 de669071-644c-4fdb-9fad-293f8decc3d2

Change Appium server URL

org.apache.maven.plugins maven-surefire-plugin 2.22.2

${suite.file} https://EPM-TSTF:${token}@mobilecloud.epam.com/wd/hub org.apache.maven.plugins maven-compiler-plugin 1.8 1.8 de669071-644c-4fdb-9fad-293f8decc3d2
Слайд 11

Dedicated Maven profile Dedicated TestNG .xml Cloud Web test run cloudWeb false ./src/test/resources/cloudWebTNG.xml

Dedicated Maven profile

Dedicated TestNG .xml

Cloud Web test run

"https://testng.org/testng-1.0.dtd">

cloudWeb false ./src/test/resources/cloudWebTNG.xml

Слайд 12

“Agile way”: simple proto => check => fix obvious => commit

“Agile way”: simple proto => check => fix obvious => commit
Modify

parameters instead source code (sic!): sut=www.iana.org platform=Android devicename=SAMSUNG SM-J320F driver=https://EPM-TSTF:6a3e096f-0ad9-4cf4-bdff-7016e684ed05 @mobilecloud.epam.com/wd/hub
Sorry, but we have to modify source code slightly…

Modify Appium driver

Слайд 13

“app” capability not useful more Use instead: Android: appPackage & appActivity

“app” capability not useful more
Use instead:
Android: appPackage & appActivity
iOS: bundleId
Install app

to target device
Manually via cloud UI
Automatically via cloud API

App accessibility

Слайд 14

You may need to use UDID instead of deviceName. It depends

You may need to use UDID instead of deviceName. It depends

on current implementation of mobile cloud software
For EPAM mobile cloud solution you can use Serial Number as a UDID
DeviceName = Manufacturer + Product

Device identification alternatives

Слайд 15

Android native app iOS native app Source code example

Android native app

iOS native app

Source code example

Native mobile testing Suite for EPAM Mobile Cloud">


Слайд 16

App processing @Parameters({"platformName", "appType", "deviceName", "udid", "browserName","app","appPackage","appActivity","bundleId"}) @BeforeSuite(alwaysRun = true) public

App processing

@Parameters({"platformName", "appType", "deviceName", "udid", "browserName","app","appPackage","appActivity","bundleId"}) @BeforeSuite(alwaysRun = true) public void setUp(String platformName,

String appType, @Optional("") String deviceName, @Optional("") String udid, @Optional("") String browserName, @Optional("") String app, @Optional("") String appPackage, @Optional("") String appActivity, @Optional("") String bundleId ) throws Exception { System.out.println("Before: app type - "+appType); setAppiumDriver(platformName, deviceName, udid, browserName, app, appPackage, appActivity, bundleId); setPageObject(appType, appiumDriver); }
Слайд 17

App processing private void setAppiumDriver(String platformName, String deviceName, String udid, String

App processing

private void setAppiumDriver(String platformName, String deviceName, String udid, String browserName,

String app, String appPackage, String appActivity, String bundleId){ DesiredCapabilities capabilities = new DesiredCapabilities(); // mandatory Android capabilities capabilities.setCapability("platformName",platformName); capabilities.setCapability("deviceName", deviceName); capabilities.setCapability("udid", udid); if(app.endsWith(".apk")) capabilities.setCapability("app", (new File(app)).getAbsolutePath()); capabilities.setCapability("browserName", browserName); capabilities.setCapability("chromedriverDisableBuildCheck","true"); // Capabilities for test of Android native app on EPAM Mobile Cloud capabilities.setCapability("appPackage",appPackage); capabilities.setCapability("appActivity",appActivity); // Capabilities for test of iOS native app on EPAM Mobile Cloud capabilities.setCapability("bundleId",bundleId); //if(platformName.equals("iOS")) capabilities.setCapability("automationName","XCUITest"); try { appiumDriver = new AppiumDriver(new URL(System.getProperty("ts.appium")), capabilities); } catch (MalformedURLException e) { e.printStackTrace(); } // Timeouts tuning appiumDriver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); }
Слайд 18

Pray or enjoy? Try existent (web) test on iOS w/o changes

Pray or enjoy?
Try existent (web) test on iOS w/o changes in

code.
Can we hope for cross-platform auto tests?

Build and run!

Слайд 19

Why it may not work for iOS native apps? No the

Why it may not work for iOS native apps?
No the same

iOS app
Different GUI design & guides
Different libs
Different target audience for Android and iOS platforms/apps
In particular: locators strategy for iOS differs from Android one (xpath mostly)
But methodology itself is cross-platform

Cross-platform troubles

Слайд 20

Cross-platform PO public class NativePageObject { @AndroidFindBy(id = "platkovsky.alexey.epamtestapp:id/email_sign_in_button") @iOSXCUITFindBy(xpath =

Cross-platform PO

public class NativePageObject { @AndroidFindBy(id = "platkovsky.alexey.epamtestapp:id/email_sign_in_button") @iOSXCUITFindBy(xpath = "//XCUIElementTypeStaticText[@label='Sign

In']") WebElement signInBtn; public NativePageObject(AppiumDriver appiumDriver) { PageFactory.initElements( new AppiumFieldDecorator(appiumDriver), this); } }
Слайд 21

Basic tools How to write auto-tests for mobile apps Basics of

Basic tools
How to write auto-tests for mobile apps
Basics of Mobile Cloud

Services
Tips and tricks

Plan