65
Using Selenium to Test Native Applications …wait, you can do that?

Using Selenium to Test Native Apps (Wait, you can do that?)

Embed Size (px)

Citation preview

Page 1: Using Selenium to Test Native Apps (Wait, you can do that?)

Using Selenium to Test Native Applications

…wait, you can do that?

Page 2: Using Selenium to Test Native Apps (Wait, you can do that?)

Hi.

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

Page 3: Using Selenium to Test Native Apps (Wait, you can do that?)

@maudineormsby

…it’s a long story.

Page 4: Using Selenium to Test Native Apps (Wait, you can do that?)

I’m a developer

and contributor to selenium and appium

Page 5: Using Selenium to Test Native Apps (Wait, you can do that?)

This talk is about…

Page 6: Using Selenium to Test Native Apps (Wait, you can do that?)

This talk is about…

the problem of ios app automation

Page 7: Using Selenium to Test Native Apps (Wait, you can do that?)

This talk is about…

lessons learned automating apps

Page 8: Using Selenium to Test Native Apps (Wait, you can do that?)

This talk is about…

the right approach to testing native apps

Page 9: Using Selenium to Test Native Apps (Wait, you can do that?)

This talk is about…

the tools available to test your apps today

Page 10: Using Selenium to Test Native Apps (Wait, you can do that?)

This talk is about…

WHAT HOPE WE HAVE FOR THE FUTURE.

Page 11: Using Selenium to Test Native Apps (Wait, you can do that?)

the problem of ios app automation

Page 12: Using Selenium to Test Native Apps (Wait, you can do that?)

“…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 13: Using Selenium to Test Native Apps (Wait, you can do that?)

jsjs Instruments.appInstruments.app App

Page 14: Using Selenium to Test Native Apps (Wait, you can do that?)

jsjs Instruments.appInstruments.app App

client device

Page 15: Using Selenium to Test Native Apps (Wait, you can do that?)

UI Automation only runs inInstruments.app

Page 16: Using Selenium to Test Native Apps (Wait, you can do that?)

Tests have to be in Javascript

Page 17: Using Selenium to Test Native Apps (Wait, you can do that?)

No realtime interaction with tests

Page 18: Using Selenium to Test Native Apps (Wait, you can do that?)

Hard to reuse code

Page 19: Using Selenium to Test Native Apps (Wait, you can do that?)

One test at a time

Page 20: Using Selenium to Test Native Apps (Wait, you can do that?)

So what have we learned so far?

Page 21: Using Selenium to Test Native Apps (Wait, you can do that?)

Two attempted approaches to automation

Page 22: Using Selenium to Test Native Apps (Wait, you can do that?)

Script/Framework

Script/Framework Screen CaptureScreen Capture App

client device

Page 23: Using Selenium to Test Native Apps (Wait, you can do that?)

Hard to abstract

Page 24: Using Selenium to Test Native Apps (Wait, you can do that?)

Very brittle

Page 25: Using Selenium to Test Native Apps (Wait, you can do that?)

Hard to use with real devices

Page 26: Using Selenium to Test Native Apps (Wait, you can do that?)

Hard to use with CI or parallelize

Page 27: Using Selenium to Test Native Apps (Wait, you can do that?)

scriptscript Client libraryClient library App

client device

Page 28: Using Selenium to Test Native Apps (Wait, you can do that?)

Requires code modification

Page 29: Using Selenium to Test Native Apps (Wait, you can do that?)

Real devices are hard

Page 30: Using Selenium to Test Native Apps (Wait, you can do that?)

New framework and new tests

Page 31: Using Selenium to Test Native Apps (Wait, you can do that?)

The right way to automate ios

Page 32: Using Selenium to Test Native Apps (Wait, you can do that?)

Remember the testing pyramid

Page 33: Using Selenium to Test Native Apps (Wait, you can do that?)
Page 34: Using Selenium to Test Native Apps (Wait, you can do that?)

Are you writing unit tests for apps?

It’s not that hard!

Page 35: Using Selenium to Test Native Apps (Wait, you can do that?)

Test your views appropriately

Page 36: Using Selenium to Test Native Apps (Wait, you can do that?)

For UIWebViews use iWebDriver

Page 37: Using Selenium to Test Native Apps (Wait, you can do that?)

Yes, yes, but now what?

Page 38: Using Selenium to Test Native Apps (Wait, you can do that?)

Code reuse is good.

Page 39: Using Selenium to Test Native Apps (Wait, you can do that?)

Realtime interaction

Page 40: Using Selenium to Test Native Apps (Wait, you can do that?)

Integrate with existing automation

Page 41: Using Selenium to Test Native Apps (Wait, you can do that?)

Parallel tests and real devices

Page 42: Using Selenium to Test Native Apps (Wait, you can do that?)

That sounds great, but how?

Page 43: Using Selenium to Test Native Apps (Wait, you can do that?)

Appium

Page 44: Using Selenium to Test Native Apps (Wait, you can do that?)

Open Source

Can be extended

Page 45: Using Selenium to Test Native Apps (Wait, you can do that?)

Uses webdriver API

Runs with off-the-shelf client libraries

Language agnostic

Page 46: Using Selenium to Test Native Apps (Wait, you can do that?)

Real time

Interact with js interpreter or client

Page 47: Using Selenium to Test Native Apps (Wait, you can do that?)

Real devices

Page 48: Using Selenium to Test Native Apps (Wait, you can do that?)

Works in parallel

(architecturally)

Page 49: Using Selenium to Test Native Apps (Wait, you can do that?)

No code modification

Page 50: Using Selenium to Test Native Apps (Wait, you can do that?)

test scripttest script

Instruments.appInstruments.appApp

client device

Appium ServerAppium Server

Page 51: Using Selenium to Test Native Apps (Wait, you can do that?)

Easy to get started

Page 52: Using Selenium to Test Native Apps (Wait, you can do that?)

Clone Appium

Page 53: Using Selenium to Test Native Apps (Wait, you can do that?)

pip install bottle

Page 54: Using Selenium to Test Native Apps (Wait, you can do that?)

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

Page 55: Using Selenium to Test Native Apps (Wait, you can do that?)

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 56: Using Selenium to Test Native Apps (Wait, you can do that?)

demo

Page 57: Using Selenium to Test Native Apps (Wait, you can do that?)

Doesn’t support execute_script()

…yet. More on this later.

Page 58: Using Selenium to Test Native Apps (Wait, you can do that?)

1 Second delay between commands

UI Automation limitation

Page 59: Using Selenium to Test Native Apps (Wait, you can do that?)

Still uses UIAutomation

‘Accessibility’ is important

Page 60: Using Selenium to Test Native Apps (Wait, you can do that?)

where do we go from here?

Page 61: Using Selenium to Test Native Apps (Wait, you can do that?)

Implement more of the API

Page 62: Using Selenium to Test Native Apps (Wait, you can do that?)

WebKit remote debugging protocol

Page 63: Using Selenium to Test Native Apps (Wait, you can do that?)

Selenium Grid support

Page 64: Using Selenium to Test Native Apps (Wait, you can do that?)

Questions?

Thank you!

Page 65: Using Selenium to Test Native Apps (Wait, you can do that?)

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