Presentation is loading. Please wait.

Presentation is loading. Please wait.

How to set UP an Appium automated framework to test mobile apps

Similar presentations


Presentation on theme: "How to set UP an Appium automated framework to test mobile apps"— Presentation transcript:

1 How to set UP an Appium automated framework to test mobile apps
Presented by Jorge Asensio © All rights reserved

2 Index PART 1: WHAT IS TESTING APPS LIKE? PART 2: APPIUM FEATURES PART 3: SETTING UP AN ANDROID FRAMEWORK PART 4: SETTING UP AN IOS FRAMEWORK PART 5: TESTING THE ANDROID APPS PART 6: TESTING THE IOS APPS PART 7: OBSTACLES AND LESSONS LEARNED © All rights reserved

3 Part 1: What is testing apps like?
HOW TO MAKE SURE AN APP IS PROPERLY TESTED © All rights reserved

4 What is in an app? An app by any other name would be as difficult to test Functional Testing Lab Testing Performance Testing Load Testing Interrupt Testing Usability Testing Installation Testing © All rights reserved

5 What is in an app? An app by any other name would be as difficult to test Certification Testing Security Testing Localisation Testing Geolocation Testing Outdated software Testing Memory Leakage Testing © All rights reserved

6 Adapting test types to the mobile app industry
Turbulent market Agile / DevOps approaches Time to market Constant competition Google / Apple restrictions Need for stable automated CI / CD set-ups © All rights reserved

7 Adapting test types to the mobile app industry
Key test types Installation Testing Interrupt Testing (networks, transactions) Usability Testing (response from users) Security Testing (especially Android) Load Testing Crowdsourced Testing / Outsourced Testing © All rights reserved

8 Part 2: APPIUM FEATURES A FRAMEWORK DESIGNED TO TEST MOBILE APPS
© All rights reserved

9 Test automation from a user perspective
Appium is meant to test apps according to: Level: Acceptance Testing Requirement Type: Functional AUT: Native, Web, Hybrid © All rights reserved

10 Appium in a nutshell Appium drives Android and iOS Applications
© All rights reserved

11 A Selenium framework for Mobile testing
Open-source, freely distributed Drives native, hybrid and web apps Supports physical and virtual devices No dependency on device OS Multiple language support Multiple integrations with tools and frameworks © All rights reserved

12 Open-source Appium is free and open source
Appium server and code bindings: Different possibilities for framework set-up © All rights reserved

13 Multiple types of app under test
Types of app supported: Native Web Hybrid © All rights reserved

14 Supports physical and virtual devices
© All rights reserved

15 Cross-platform © All rights reserved

16 Multiple language support
© All rights reserved

17 Multiple integrations with tools and frameworks
© All rights reserved

18 Continuous Integration / Continuous Deployment
Can trigger tests from the major CI / CD servers © All rights reserved

19 Part 3: SETTING UP AN IOS FRAMEWORK
iOS + Appium © All rights reserved

20 Previous knowledge required
Java Mac OS X Terminal / Windows Command X-Code Selenium © All rights reserved

21 The Appium approach proposed
Testcase.java Testng.xml © All rights reserved

22 3.1.1 Installing Appium and dependencies
First install Node.js Installer \ Binaries (Win, MacOS, Linux): Homebrew (MacOS, Linux) Install Carthage © All rights reserved

23 3.1.2 Installing Appium and dependencies
Set JAVA_HOME in .bash profile Locate JDK Edit bash_profile Input 2 export lines Save and restart Terminal Install authorize-ios Install ios-deploy © All rights reserved

24 3.1.3 Installing Appium and dependencies
Install ideviceinstaller Install ios_webkit_debug_proxy Install Appium (follow for a specific version) Install and test Appium Doctor © All rights reserved

25 3.1.4 Installing Appium and dependencies
Branch the device in a USB port and test connection (UDID): © All rights reserved

26 3.1.5 Installing Appium and dependencies
Install Maven and check version Add the Maven path line to .bash_profile © All rights reserved

27 3.1.6 Installing Appium and dependencies
Install Maven and check version Add the Maven path line to .bash_profile © All rights reserved

28 3.2.1 Apple Developer Account Settings
Get the Team ID Register the device under test © All rights reserved

29 3.2.2 Apple Developer Account Settings
Get the Team ID Register the device under test © All rights reserved

30 3.3.1 Installing and configuring X-Code
Install X-Code. This is needed to build the AUT Access the AppStore and download/install X-Code © All rights reserved

31 3.3.2 Installing and configuring X-Code
Download the X-Code project WebDriverAgent from WenDriverAgent is a WebDriver server to remote control iOS devices © All rights reserved

32 3.3.3 Installing and configuring X-Code
Run the WebDriverAgent Project on X-Code Configure the parameters: Product Name Team: matches the team stated on the Apple Developer account Organisation Name Organisation Identifier: follows the pattern com.string Bundle identifier: follows the pattern com.string.WebDriverAgentRunner © All rights reserved

33 3.3.4 Installing and configuring X-Code
On General / Signing, the Team of the Apple Developer ID must be identified and selected. With this Team ID a Provisioning Profile will be provided and signed com.ucaat.WebDriverAgentRunner © All rights reserved

34 3.3.5 Installing and configuring X-Code
Next to the layout options, display the menu to select devices and simulators Select the branched device to build the AUT © All rights reserved

35 3.4 Setting up the device Select Settings on your iOS device and select Developer Switch Enable UI Automation on © All rights reserved

36 3.5 Setting IDE and plug-ins up
Download and install Eclipse Install TestNG plug-in: launch Eclipse, hit Help > Install New Software, paste into Work with and hit Enter. © All rights reserved

37 3.6 Code dependencies Open a new Maven project on Eclipse
Open the POM.xml file and add dependencies © All rights reserved

38 3.7.1 Writing the test class Create a class (e.g. AppTest)
Import the necessary libraries Appium Classes to drive iOS: IOSDriver, IOSElement © All rights reserved

39 3.7.2 Writing the test class a) Functions to run before the execution of the test suite b) Set localhost URL c) Set up capabilities d) Initialise driver with URL and capabilities. Like Selenium © All rights reserved

40 3.7.3 Writing the test class Regarding the basic capabilities:
Device Name Device UDID Platform App Automation: XCUITest xcodeOrgId: Apple Team ID Bundle ID © All rights reserved

41 3.7.4 Writing the test class Automation: XCUITest
Only 2 automation engines for iOS: XCUITest (preferred) YouiEngine © All rights reserved

42 3.7.5 Writing the test class Capabilities for a real device: Team ID
X-Code Signing ID © All rights reserved

43 3.7.6 Writing the test class Capabilities for a real device (2): UDID
iTunes Terminal © All rights reserved

44 3.7.7 Writing the test class Capabilities for a real device (2):
APP: IPA file Device name © All rights reserved

45 3.7.8 Writing the test class Capabilities for a real device (3):
Bundle ID © All rights reserved

46 3.7.9 Writing the test class e) Functions that will be run after every test suite f) Test Case methods © All rights reserved

47 3.7.10 Writing the test class: checking elements
Inspecting elements: Appium element inspector: Enter device model Enter OS version There are others from different developers © All rights reserved

48 3.8.1 Running the appium server
Can be done by simply entering this on Terminal (default port 4723): Alternative 1: Appium Desktop Download and install the Appium Desktop application: © All rights reserved

49 3.8.2 Running the appium server
Alternative 2: programmatically Implementing AppiumDriverLocalService: 1 2 3 4 AppiumDriverLocalService service = AppiumDriverLocalService.buildDefaultService(); service.start(); // the tests to be executed, like the test file example stated on // the slides earlier service.stop(); © All rights reserved

50 3.8.3 Running the appium server
Alternative 2: programmatically Implementing AppiumServiceBuilder import org.openqa.selenium.remote.DesiredCapabilities; import io.appium.java_client.service.local.AppiumDriverLocalService; import io.appium.java_client.service.local.AppiumServiceBuilder; import io.appium.java_client.service.local.flags.GeneralServerFlag; public class AppiumServerJava { private AppiumDriverLocalService service; private AppiumServiceBuilder builder; private DesiredCapabilities cap; public void startServer() { //Set Capabilities cap = new DesiredCapabilities(); cap.setCapability("noReset", "false"); //Build the Appium service builder = new AppiumServiceBuilder(); builder.withIPAddress(" "); builder.usingPort(4723); builder.withCapabilities(cap); builder.withArgument(GeneralServerFlag.SESSION_OVERRIDE); builder.withArgument(GeneralServerFlag.LOG_LEVEL,"error"); //Start the server with the builder service = AppiumDriverLocalService.buildService(builder); service.start(); } © All rights reserved

51 3.8.4 Running the appium server
Alternative 2: programmatically Implementing AppiumServiceBuilder (2) public void stopServer() { service.stop(); } public boolean checkIfServerIsRunnning(int port) { boolean isServerRunning = false; ServerSocket serverSocket; try { serverSocket = new ServerSocket(port); serverSocket.close(); } catch (IOException e) { //If control comes here, then it means that the port is in use isServerRunning = true; } finally { serverSocket = null; return isServerRunning; © All rights reserved

52 3.8.5 Running the appium server
Alternative 2: programmatically Implementing AppiumServiceBuilder (3) public static void main(String[] args) { AppiumServerJava appiumServer = new AppiumServerJava(); int port = 4723; if(!appiumServer.checkIfServerIsRunnning(port)) { appiumServer.startServer(); appiumServer.stopServer(); } else { System.out.println("Appium Server already running on Port - " + port); } © All rights reserved

53 3.9 Checking device status
iOS webkit debug proxy: one instance per device UDID_DEVICE: device identifier FREE_PORT: an unused port idevice_id ios_webkit_debug_proxy -c UDID_DEVICE:FREE_PORT © All rights reserved

54 3.10 Ready up the Testng.xml file
Test name: name of the suite that will show on reports Parameters: parametrise values that change from one device \ test environment from another. Class: test class that must be executed to trigger test cases © All rights reserved

55 3.11.1 Run a TestNG test case with Appium
Right-click on the testng.xml file / Run As / TestNG Suite © All rights reserved

56 3.11.2 Run a TestNG test case with Appium
Reports: multiple types. Configurable with Appium-Java libraries XML, HTML, JSON © All rights reserved

57 Minimum Requirements summary
Apple Developer ID Mac with XCode Eclipse with TestNG Appium libraries and dependencies Java Maven Test class © All rights reserved

58 Part 4: SETTING UP AN ANDROID FRAMEWORK
Android + Appium © All rights reserved

59 4.1.1 Install Appium Dependencies
Node.js and NPM remain necessary Java remains necessary Install Android SDK, Command line tools only: © All rights reserved

60 4.1.2 Install Appium Dependencies
Check the location of the following essential folders: platform-tools tools Update paths on bash_profile, by adding the following: Then save and quit © All rights reserved

61 4.2 Android SDK Manager Access the Android directory
Run Android SDK Manager Select the SDK Platform to match Android versions Hit Install packages… © All rights reserved

62 4.3.1 Configuring the Android device
Branch the phone into a USB port. Select Settings / About phone Tap 7 times in quick succession on Build number. The toast message You are now a developer! will pop up © All rights reserved

63 4.3.2 Configuring the Android device
Fall back to Settings and locate Develop Options Check the option USB debugging. © All rights reserved

64 4.3.3 Configuring the Android device
Hit OK on confirmation message. Confirm the computer returns the RSA key © All rights reserved

65 4.4 Checking Android connectivity
Open the terminal Run the Android Device Bridge (ADB) command (same for Windows command): The device ID will show: © All rights reserved

66 4.5.1 Android plug-in on Eclipse
Open Eclipse and hit Help / Install New Software Add the following on Work with and hit OK Check Developer Tools / Next / Finish © All rights reserved

67 4.5.2 Android plug-in on Eclipse
Hit Window / Preferences / Android Make sure the path to SDK is correct, then hit Apply / OK © All rights reserved

68 4.6.1 Checking elements Run Appium desktop application
Hit the Android button Hit the settings menu and fill up with the information; same way as iOS. © All rights reserved

69 4.6.2 Checking elements Run uiautomatorviewer on Terminal or Windows Command Get a screenshot and identify elements Not all elements visible © All rights reserved

70 4.7 Different capabilities
Running the Appium server remains the same Capabilities are different Classes to drive Android: AndroidDriver, MobileElement Native app vs hybrid app: Many automation engines: UIAutomator, Espresso, Selendroid. © All rights reserved

71 Part 5: TESTING THE APPS ESSENTIAL OPERATIONS WITH APPIUM
© All rights reserved

72 Common basic operations: the Selenium way
Declaring a driver with capabilities Finding an element Waiting for an element Operations with elements driver = new IOSDriver<IOSElement>(“ capabilities) driver2 = new AndroidDriver<AndroidElement>(“ capabilities) IOSElement e = AndroidElement e = import org.openqa.selenium.support.ui.WebDriverWait; WebDriverWait webDriverWait; webDriverWait.until(ExpectedConditions.visibilityOfElementLocated(elementBy)); e.click(), e.sendKeys(), e.getText(), e.navigate(), e.close(), e.quit()… © All rights reserved

73 Part 6: OBSTACLES AND EXPERIENCES: iOS
What has to be taken into account setting up Appium and iOS © All rights reserved

74 Restrictions with Apple
Tricky set-up Need an Apple machine Need an Apple Dev account X-Code deployment © All rights reserved

75 Tricky set-up Many dependencies
Alignment of versions of the parts involved: obsolescence of software and hardware © All rights reserved

76 Tricky set-up Maintenance of framework Complex parallel execution
Derived from the dependencies and integrable components Complex parallel execution Individual proxy set-up Lately idb has improved for device and simulator parallel testing: © All rights reserved

77 X-Code deployment Necessary to build the app under test
WebDriver Agent crashes often © All rights reserved

78 Need an Apple machine Necessary to install the app under test in the device Appium relies on native OS X libraries to support iOS testing Costly © All rights reserved

79 Need an Apple Developer account
Need to sign in on X-Code prior to test-building Requires a paid subscription © All rights reserved

80 Part 7: OBSTACLES AND EXPERIENCES: Android
What has to be taken into account setting up Appium and Android © All rights reserved

81 Appium Android Specific SDK for each Android version
Very heavy SDK files Differences and conflicts linked to automation engines Different Android implementations (device brands) require additional coding © All rights reserved

82 Part 7: CHALLENGES What is on the horizon? © All rights reserved

83 What could be improved? Increase the simplicity for automation:
iOS set up Automation engines on Android Allow automation under no Apple Developer policy? More facilities to test with certain CI servers (Jenkins) Improved smart device proxy selection © All rights reserved

84 BIBLIOGRAPHY Sauce Labs www.saucelabs.com
Today Software Magazine Appium project Research Gate Software Testing Class Android Apple © All rights reserved

85 Thank you for your attention!
Any questions? © All rights reserved


Download ppt "How to set UP an Appium automated framework to test mobile apps"

Similar presentations


Ads by Google