11
§ January 2015 Appium Meetup #2 Mobile Web Automation Introduction Sergio Neves Barros QA Automation Technical Lead

Appium Meetup #2 - Mobile Web Automation Introduction

Embed Size (px)

Citation preview

Page 1: Appium Meetup #2 - Mobile Web Automation Introduction

§

January 2015

Appium Meetup #2 Mobile Web Automation

Introduction

Sergio Neves BarrosQA Automation Technical Lead

Page 2: Appium Meetup #2 - Mobile Web Automation Introduction

January 2015

1. Who and what

2. A bit of history

3. Setup

4. Writing tests

5. Test execution (demo)

6. Questions

Overview

Page 3: Appium Meetup #2 - Mobile Web Automation Introduction

January 2015

Who and whatWho I am:For over 10 years I have been working as a tester across various industries such as Insurance, Banking and Gaming. Around 3 years ago I joined Gamesys and we have been developing and maintaining our test automation and training QA’s on testing and test automation best practices. As a team we have developed various drivers to interact/interrogate the technologies we test (e.g. Flash/HTML5 Canvas) and also contributed to open source tools.

What we do at Gamesys:Gamesys develops and manages various sites such as Jackpotjoy, SunBingo, HeartBingo and Virgin Games for which we develop and test a wide variety games such as Slots, Bingo and Poker. We also work with quite a few technologies such as HTML5 Canvas, Flash, Android and iOS, which as you can imagine makes testing a real challenge.

Page 4: Appium Meetup #2 - Mobile Web Automation Introduction

January 2015

A bit of historyMy question (April 2013):“I am trying to grab the window_handles on the WebViewApp and this is working fine on a iphone simulator, however it's throwing an unhandled exception on a real device”

Jonathan Lipps:“This is unfortunately expected. Webview support works by creating a TCP connection to the remote webkit debugger run in Safari/webviews. Even though the real device might be running a webkit debugger, it's almost definitely not forwarding that port to the host, where appium is running.Someone will need to figure out how to reverse engineer the USB debugging protocol and forward the port from the device to the host---

sounds like it will be challenging at best and maybe impossible at worst.”

Luckily someone had already figured a way to forward requests to a physical device and we just connected the dots.

Page 5: Appium Meetup #2 - Mobile Web Automation Introduction

January 2015

Setup - Safari on iOS SimulatorTo run a your mobile web tests on a simulator you will need the following tools.

• Xcode (including command line tools)• Can be installed from the App store or from the Apple developer portal.• Any additional Simulators can be downloaded in preferences.

• Nodejs• Simply download and install nodejs.

• Appium• To run the simulator tests you can use:

• the Appium app • or clone the project and run “./reset.sh --ios”

Page 6: Appium Meetup #2 - Mobile Web Automation Introduction

January 2015

In addition to the previous setup, to run your mobile web tests on safari on a physical device you will need the Safari Launcher and the ios-webkit-debugger-proxy.

• Safari Launcher app• Add “--real-safari” argument when running reset.sh• To build & install safari you will need a valid development profile (figure 1)• NOTE: You can not use the Appium App to install the safari launcher on a device.

Figure1: iOS development provisioning profile setup

• ios-webkit-debugger-proxy• Can be installed using brew• Turn on web inspector (available on iOS 6.0 or higher) in Safari settings.• NOTE: due to an issue with the proxy you should use the proxy launcher script.

Setup – Safari on iOS Device

Device Id(s)

App Id (or wildcard)

Development Certificate(s)

Development Provisioning Profile

Page 7: Appium Meetup #2 - Mobile Web Automation Introduction

January 2015

Setup – Chrome on Android DeviceTo run a your mobile web tests on an Android Device with Chrome you will need:

• Android SDK• Make sure you install the relevant API for the version of Android you want to test against.

• Just run “android” in the terminal and the android sdk manager will launch where you can install additional API’s.

• Also make sure to:• configure ANDROID_HOME • and add both the tools & platform-tools folder to your PATH.

• Nodejs• Simply download and install nodejs.

• Appium• To run the emulator tests you can use the Appium app or clone the project and run:

• “reset.sh –android”

NOTE: You can not (simply) install chrome on an emulator through the app store (as emulator doesn’t have the the app store). You will have to find a valid version of the chrome app (built for the right architecture).

Page 8: Appium Meetup #2 - Mobile Web Automation Introduction

January 2015

Writing tests – Useful toolsChrome Debugger (Android):

• You can use the Chrome Debugger by going to chrome://inspect on your desktop chrome.• Make sure that:

• Your android device is attached and unlocked• Remote debugging is turned on in developer options• Chrome is installed on the android device.

Safari Debugger (iOS): • You can use the Safari Debugger by going to the develop menu

• Make sure that:• Your iOS device is attached and unlocked or your simulator is started.• That “web inspector” is turned on (iOS 6.0 and higher) on your device.

The debuggers will allow you to:• Inspect web elements e.g. to get element identifiers.• Execute JavaScript on the pages

• Trick: xpath checker: $x("//*[@name='q']") • Trigger a listener (mouse up/down etc..)

• See any errors in the javascript logs.• See the page (Chrome only)

Page 9: Appium Meetup #2 - Mobile Web Automation Introduction

January 2015

Writing tests – Java Client• Appium Java Client:

• The drivers extend the RemoteWebDriver• The iOS Driver and Android Driver both have platform specific

configuration and methods already added.• Simply add the maven dependency to your project (e.g. similar to

Selenium) and start using the iOS Driver/Android Driver• Can be found on github:

• https://github.com/appium/java-client

• Selenium Tests Reusable:• When writing your tests you can re-use your existing selenium tests• The only real difference will be the desired capabilities:

• platformName: iOS, Android, FirefoxOS• platformVersion: 4.2.2, 8.1, 7.1• automationName: Appium, Selendroid (Android specific)• deviceName: iPad 2, Galaxy S5• browserName: Chrome, Safari

Page 10: Appium Meetup #2 - Mobile Web Automation Introduction

January 2015

Executing testsStarting Appium Server (app/terminal):• You can either use the appium app to start the server

• And it will display all the possible arguments• Or you can run the following command in the terminal:

• > node lib/server/main.js• Add “—help” to see all the arguments

Demo Time!This is the bit where I make a fool out of myself with a live demo …murphy’s law.

Note: the demo maven project can be found here

Page 11: Appium Meetup #2 - Mobile Web Automation Introduction

§

January 2015

Questions?