Automate your mobile app testing About This Book How to automate testing with Appium Apply techniques for creating comprehensive tests How to test on physical devices or emulators Who This Book Is For Are you a mobile developer or a software tester who wishes to use Appium for your test automation? If so, then this is the right book for you .You must have basic Java programming knowledge. You don't need to have prior knowledge of Appium. What You Will Learn Discover Appium and how to set up an automation framework for mobile testing Understand desired capabilities and learn to find element locators Learn to automate gestures and synchronize tests using Appium Take an incremental approach to implement page object pattern Learn to run Appium tests on emulators or physical devices Set up Jenkins to run mobile automation tests by easy to learn steps Discover tips and tricks to record video of test execution, inter app automation concepts Learn to run Appium tests in parallel on multiple devices simultaneously In Detail Appium is an open source test automation framework for mobile applications. It allows you to test all three types of mobile applications: native, hybrid, and mobile web. It allows you to run the automated tests on actual devices, emulators, and simulators. Today, when every mobile app is made on at least two platforms, iOS and Android, you need a tool that allows you to test across platforms. Having two different frameworks for the same app increases the cost of the product and time to maintain it as well. Appium helps save this cost. With mobile app growth exploding, mobile app automation is mainstream now. In this book, author Nishant Verma provides you with a firm grounding in the concepts of Appium while diving into how to set up appium & Cucumber-jvm test automation framework, implement page object design pattern, automate gestures, test execution on emulators and physical devices, and implement continuous integration with Jenkins. The mobile app we have referenced in this book is Quikr because of its relatively lower learning curve to understand the application. It's a local classifieds shopping app. Style and approach This book takes a practical, step-by-step approach to testing and automating individual apps such as native, hybrid, and mobile web apps using different examples Cover 1 Copyright 3 Credits 4 About the Author 5 About the Reviewers 6 www.PacktPub.com 7 Customer Feedback 8 Table of Contents 9 Preface 13 Chapter 1: Introduction to Appium 20 Native app 21 Mobile Web app 23 Hybrid app 25 Appium architecture 27 XCUITest 29 UiAutomator 2 30 Pros of using Appium 31 Summary 31 Chapter 2: Setting Up the Machine 32 Machine setup for macOS 33 Installing Java 33 Installing Android SDK (using the Android command-line tool) 34 Installing Android SDK (using Homebrew) (Optional) 35 Creating Android Virtual Device (Optional) 35 Genymotion emulator 37 Debug help 41 Installing Appium 42 Installing Appium server (From Source) (Optional) 44 Selecting IDE 44 App under test 44 Machine setup for Windows 44 Installing Java 45 Installing Android SDK (using Android command-line tool) 45 Installing Node JS 48 Installing Appium 48 Installing Appium server (via npm) 49 Installing Genymotion 49 Selecting IDE 50 Appium GUI app 50 Summary 56 Chapter 3: Writing Your First Appium Test 57 Creating an Appium Java project (using gradle) 58 Introduction to Cucumber 62 Writing our first Appium test 63 Running the feature file 76 Refactoring 78 Implementing the remaining steps 78 Running the scenario 84 Automating a mobile web app using Appium 85 Implementing the remaining steps 86 Automating the iOS app using Appium 89 Build the app 90 Deploying the app on the iOS Simulator 91 Via xcrun command 91 Using Appium 91 Generating Boilerplate code for iOS 94 Summary 100 Chapter 4: Understanding Desired Capabilities 101 Refactoring -1 102 Server argument 104 Refactoring -2 105 Server capabilities 109 Refactoring -3 111 Android-only capabilities 112 Refactoring -4 115 iOS-only capabilities 117 Summary 122 Chapter 5: Understanding Appium Inspector to Find Locators 123 Appium inspector 123 Implementing the other steps 127 UI Automator Viewer 130 Debugging mobile web apps using Chrome Inspect 133 Summary 135 Chapter 6: How to Synchronize Tests 136 AppiumDriver 136 Implicit wait 138 Explicit wait 138 Fluent wait 141 Summary 143 Chapter 7: How to Automate Gestures 144 Gestures 144 TouchAction 144 MultiTouch 149 Scroll 150 Swipe 151 Orientation 152 Summary 153 Chapter 8: Design Patterns in Test Automation 154 Refactor -1 155 Page Object pattern 160 Refactor-2 162 Assertions 168 Implementing assertions in Page Object 168 Implementing assertion in test script 170 Avoiding dependencies between tests 171 Introducing set up and tear down 171 Summary 172 Chapter 9: How to Run Appium Test on Devices and Emulators 173 Emulator 173 Running test on the Genymotion emulator 175 Devices 177 Running a test on actual Android devices 181 Running a test on actual iOS devices 181 Summary 184 Chapter 10: Continuous Integration with Jenkins 185 Refactoring -1 186 Setting up Jenkins 190 Moving a project to Git 192 Adding Jenkins plugin 196 Setting up the Jenkins task 198 Viewing reports in Jenkins 202 Summary 204 Chapter 11: Appium Tips and Tricks 205 Switching between views - web and native 205 Taking screenshots 206 Recording video execution 209 Interacting with another app 210 Running the test in parallel 212 Network conditioning 214 Summary 216 Chapter 12: Appium Desktop App 217 Installing the new Appium app 217 Starting a simple server 219 Start New Session 220 Attach to an existing session 221 Desired Capabilities 221 Appium Inspector 222 Starting the server with advanced options 224 Appium Endpoints 226 Summary 227 Appendix 228 Introduction to Cucumber 228 How does Cucumber work? 229 Feature 231 Scenario 232 Background 234 Scenario Outline 236 Hooks in Cucumber 237 Running Cucumber 238 CLI Runner 238 JUnit Runner 238 Third-Party Runner (Via IntelliJ) 239 Finding an app's package name and launch activity 240 Using the ManifestViewer app 240 Using the Appium GUI app 243 Installing Google Play services in the Genymotion emulator 244 Summary 245 Index 246