These were the slides for the second appium meetup held at the Gamesys in London, presented by Dan Cueller and Sergio Neves Barros
The demo project mentioned in the slides can be found here:
https://drive.google.com/file/d/0ByIdcWPvw1I3Ny1QWkJzZWpvbzA/view?usp=sharing
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
Appium Meetup #2 - Mobile Web Automation Introduction
1. §
January 2015
Appium Meetup #2
Mobile Web Automation Introduction
Sergio Neves Barros
QA Automation Technical Lead
2. January 2015
1. Who and what
2. A bit of history
3. Setup
4. Writing tests
5. Test execution (demo)
6. Questions
Overview
3. January 2015
Who and what
Who 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.
4. January 2015
A bit of history
My 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.
5. January 2015
Setup - Safari on iOS Simulator
To 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”
6. 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
7. January 2015
Setup – Chrome on Android Device
To 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).
8. January 2015
Writing tests – Useful tools
Chrome 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)
9. 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
10. January 2015
Executing tests
Starting 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
For more information on myself:
https://www.linkedin.com/profile/view?id=12608927
For more information on gamesys go to:
http://www.gamesyscorporate.com/
Link to quote:
https://groups.google.com/forum/#!topic/appium-discuss/u1ropm4OEbY
The communicate with safari on the simulator appium uses the WebInspector Protocol.
No obstacles to communicate between simulator and Appium
However on a physical device the communication happens through the cable (and therefore we need the ios-webkit-debugger-proxy)
You also need the safariLauncher to navigate to a url which triggers safari to be launched (as instruments can not launch safari on a physical device).
The unique identifier of a device can be found in Xcode (xcode \ window \ devices)
You can also provide your own code signing identity and/or profile.
Description: https://github.com/appium/appium/blob/master/docs/en/writing-running-appium/mobile-web.md
Two fixes for instability with ios-webkit-debug-proxy:
Use the following command in the appium folder to launch the proxy.
./bin/ios-webkit-debug-proxy-launcher.js -c <udid>:27753
Or use the fix by James
https://github.com/jchuong/ios-webkit-debug-proxy
You will have to build and run it yourself using the following commands:
> ./autogen.sh
> ./configure
> make
src/.ios_webkit_debug_proxy –c <udid>:27753 –d
Once you have the Android SDK setup and installed run the command “android” in the terminal to show the API version and the Android versions.
NOTE: To build the latest version of Selendroid you need Java 7.
Tutorial on how to debug chrome on Android:
https://developer.chrome.com/devtools/docs/remote-debugging
Protocol that google uses to debug.
https://developer.chrome.com/devtools/docs/protocol/1.1/index
Safari Web Inspector:
https://developer.apple.com/safari/tools/