Post on 09-May-2015
The future of Selenium testing for mobile web and native apps
Hi.
I’m JASON CARR. I work at sauce LABS.
@maudineormsby
I’m a developer
and contributor to selenium and appium
Context
For mobile web, Web Driver
ScriptScript Selenium Grid(optional)
Selenium Grid(optional)
iWebDriver.app
ScriptScript iWebDriver.app
iWebDriver.app
from selenium import webdriver
hub = ‘http://localhost:3001/wd/hub’caps = webdriver.DesiredCapabilities.IPHONE
driver = webdriver.Remote(hub, caps)
from selenium import webdriver
hub = ‘http://localhost:3001/wd/hub’caps = webdriver.DesiredCapabilities.IPHONE
driver = webdriver.Remote(hub, caps)
Limitations
iframes
driver.quit()
Alert handling
Javascript
UIAutomation
“…a bit like being dropped off in a field somewhere with no map, tools or supplies and being told you need to build a house.”
-Alex Vollmer
jsjs Instruments.appInstruments.app App
jsjs Instruments.appInstruments.app App
client device
UI Automation only runs inInstruments.app
Tests have to be in Javascript
No realtime interaction with tests
Hard to reuse code
One test at a time
An aside:Android automation…
Monkey Runner
So what have we learned so far?
Two attempted approaches to automation
Script/Framework
Script/Framework Screen CaptureScreen Capture App
client device
Hard to abstract
Very brittle
Hard to use with real devices
Hard to use with CI or parallelize
scriptscript Client libraryClient library App
client device
Requires code modification
Real devices are hard
New framework and new tests
The right way to automate ios
Remember the testing pyramid
Are you writing unit tests for apps?
It’s not that hard!
Test your views appropriately
For UIWebViews use iWebDriver
Yes, yes, but now what?
Code reuse is good.
Realtime interaction
Integrate with existing automation
Parallel tests and real devices
That sounds great, but how?
Appium
Open Source
Can be extended
Uses webdriver API
Runs with off-the-shelf client librariesLanguage agnostic
Real time
Interact with js interpreter or client
Real devices
Works in parallel
(architecturally)
No code modification
test scripttest script
Instruments.appInstruments.appApp
client device
Appium ServerAppium Server
Easy to get started
Clone Appium
pip install bottle
python server.py /path/to/my.app
from selenium import webdriver
command_url = “http://localhost:4723/wd/hub”iphone = webdriver.DesiredCapabilities.IPHONE
driver = webdriver.Remote(command_url, iphone)
fields = driver.find_elements_by_tag_name('textField’)fields[0].send_keys(3)fields[1].send_keys(4)
buttons = driver.find_elements_by_tag_name('button’)buttons[0].click()
demo
Doesn’t support execute_script()
…yet. More on this later.
1 Second delay between commands
UI Automation limitation
Still uses UIAutomation
‘Accessibility’ is important
where do we go from here?
WebKit remote debugging protocol
Drive mobile safari
Drive desktop safari
Drive chrome on android!
Android RC
Questions?
Thank you!
ResourcesAppium Github Repo:http://goo.gl/4E5F0Dan Cuellar’s talk on Appium:http://goo.gl/qgLha François Reynaud on ios-driver:http://goo.gl/pzn75 Simon Stewart’s blog on mobile testing:http://goo.gl/8wl8j