75
The future of Selenium testing for mobile web and native apps

The Future of Selenium Testing for Mobile Web and Native Apps

Embed Size (px)

Citation preview

Page 1: The Future of Selenium Testing for Mobile Web and Native Apps

The future of Selenium testing for mobile web and native apps

Page 2: The Future of Selenium Testing for Mobile Web and Native Apps

Hi.

I’m JASON CARR. I work at sauce LABS.

Page 3: The Future of Selenium Testing for Mobile Web and Native Apps

@maudineormsby

Page 4: The Future of Selenium Testing for Mobile Web and Native Apps
Page 5: The Future of Selenium Testing for Mobile Web and Native Apps

I’m a developer

and contributor to selenium and appium

Page 6: The Future of Selenium Testing for Mobile Web and Native Apps

Context

Page 7: The Future of Selenium Testing for Mobile Web and Native Apps

For mobile web, Web Driver

Page 8: The Future of Selenium Testing for Mobile Web and Native Apps

ScriptScript Selenium Grid(optional)

Selenium Grid(optional)

iWebDriver.app

Page 9: The Future of Selenium Testing for Mobile Web and Native Apps

ScriptScript iWebDriver.app

Page 10: The Future of Selenium Testing for Mobile Web and Native Apps

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)

Page 11: The Future of Selenium Testing for Mobile Web and Native Apps
Page 12: The Future of Selenium Testing for Mobile Web and Native Apps

Limitations

Page 13: The Future of Selenium Testing for Mobile Web and Native Apps

iframes

Page 14: The Future of Selenium Testing for Mobile Web and Native Apps

driver.quit()

Page 15: The Future of Selenium Testing for Mobile Web and Native Apps

Alert handling

Page 16: The Future of Selenium Testing for Mobile Web and Native Apps

Javascript

Page 17: The Future of Selenium Testing for Mobile Web and Native Apps

UIAutomation

Page 18: The Future of Selenium Testing for Mobile Web and Native Apps

“…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

Page 19: The Future of Selenium Testing for Mobile Web and Native Apps

jsjs Instruments.appInstruments.app App

Page 20: The Future of Selenium Testing for Mobile Web and Native Apps

jsjs Instruments.appInstruments.app App

client device

Page 21: The Future of Selenium Testing for Mobile Web and Native Apps

UI Automation only runs inInstruments.app

Page 22: The Future of Selenium Testing for Mobile Web and Native Apps

Tests have to be in Javascript

Page 23: The Future of Selenium Testing for Mobile Web and Native Apps

No realtime interaction with tests

Page 24: The Future of Selenium Testing for Mobile Web and Native Apps

Hard to reuse code

Page 25: The Future of Selenium Testing for Mobile Web and Native Apps

One test at a time

Page 26: The Future of Selenium Testing for Mobile Web and Native Apps

An aside:Android automation…

Page 27: The Future of Selenium Testing for Mobile Web and Native Apps

Monkey Runner

Page 28: The Future of Selenium Testing for Mobile Web and Native Apps

So what have we learned so far?

Page 29: The Future of Selenium Testing for Mobile Web and Native Apps

Two attempted approaches to automation

Page 30: The Future of Selenium Testing for Mobile Web and Native Apps

Script/Framework

Script/Framework Screen CaptureScreen Capture App

client device

Page 31: The Future of Selenium Testing for Mobile Web and Native Apps

Hard to abstract

Page 32: The Future of Selenium Testing for Mobile Web and Native Apps

Very brittle

Page 33: The Future of Selenium Testing for Mobile Web and Native Apps

Hard to use with real devices

Page 34: The Future of Selenium Testing for Mobile Web and Native Apps

Hard to use with CI or parallelize

Page 35: The Future of Selenium Testing for Mobile Web and Native Apps

scriptscript Client libraryClient library App

client device

Page 36: The Future of Selenium Testing for Mobile Web and Native Apps

Requires code modification

Page 37: The Future of Selenium Testing for Mobile Web and Native Apps

Real devices are hard

Page 38: The Future of Selenium Testing for Mobile Web and Native Apps

New framework and new tests

Page 39: The Future of Selenium Testing for Mobile Web and Native Apps

The right way to automate ios

Page 40: The Future of Selenium Testing for Mobile Web and Native Apps

Remember the testing pyramid

Page 41: The Future of Selenium Testing for Mobile Web and Native Apps
Page 42: The Future of Selenium Testing for Mobile Web and Native Apps

Are you writing unit tests for apps?

It’s not that hard!

Page 43: The Future of Selenium Testing for Mobile Web and Native Apps

Test your views appropriately

Page 44: The Future of Selenium Testing for Mobile Web and Native Apps

For UIWebViews use iWebDriver

Page 45: The Future of Selenium Testing for Mobile Web and Native Apps

Yes, yes, but now what?

Page 46: The Future of Selenium Testing for Mobile Web and Native Apps

Code reuse is good.

Page 47: The Future of Selenium Testing for Mobile Web and Native Apps

Realtime interaction

Page 48: The Future of Selenium Testing for Mobile Web and Native Apps

Integrate with existing automation

Page 49: The Future of Selenium Testing for Mobile Web and Native Apps

Parallel tests and real devices

Page 50: The Future of Selenium Testing for Mobile Web and Native Apps

That sounds great, but how?

Page 51: The Future of Selenium Testing for Mobile Web and Native Apps

Appium

Page 52: The Future of Selenium Testing for Mobile Web and Native Apps

Open Source

Can be extended

Page 53: The Future of Selenium Testing for Mobile Web and Native Apps

Uses webdriver API

Runs with off-the-shelf client librariesLanguage agnostic

Page 54: The Future of Selenium Testing for Mobile Web and Native Apps

Real time

Interact with js interpreter or client

Page 55: The Future of Selenium Testing for Mobile Web and Native Apps

Real devices

Page 56: The Future of Selenium Testing for Mobile Web and Native Apps

Works in parallel

(architecturally)

Page 57: The Future of Selenium Testing for Mobile Web and Native Apps

No code modification

Page 58: The Future of Selenium Testing for Mobile Web and Native Apps

test scripttest script

Instruments.appInstruments.appApp

client device

Appium ServerAppium Server

Page 59: The Future of Selenium Testing for Mobile Web and Native Apps

Easy to get started

Page 60: The Future of Selenium Testing for Mobile Web and Native Apps

Clone Appium

Page 61: The Future of Selenium Testing for Mobile Web and Native Apps

pip install bottle

Page 62: The Future of Selenium Testing for Mobile Web and Native Apps

python server.py /path/to/my.app

Page 63: The Future of Selenium Testing for Mobile Web and Native Apps

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()

Page 64: The Future of Selenium Testing for Mobile Web and Native Apps

demo

Page 65: The Future of Selenium Testing for Mobile Web and Native Apps

Doesn’t support execute_script()

…yet. More on this later.

Page 66: The Future of Selenium Testing for Mobile Web and Native Apps

1 Second delay between commands

UI Automation limitation

Page 67: The Future of Selenium Testing for Mobile Web and Native Apps

Still uses UIAutomation

‘Accessibility’ is important

Page 68: The Future of Selenium Testing for Mobile Web and Native Apps

where do we go from here?

Page 69: The Future of Selenium Testing for Mobile Web and Native Apps

WebKit remote debugging protocol

Page 70: The Future of Selenium Testing for Mobile Web and Native Apps

Drive mobile safari

Page 71: The Future of Selenium Testing for Mobile Web and Native Apps

Drive desktop safari

Page 72: The Future of Selenium Testing for Mobile Web and Native Apps

Drive chrome on android!

Page 73: The Future of Selenium Testing for Mobile Web and Native Apps

Android RC

Page 74: The Future of Selenium Testing for Mobile Web and Native Apps

Questions?

Thank you!

Page 75: The Future of Selenium Testing for Mobile Web and Native Apps

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