mobile test automation using one api and one infrastructure
DESCRIPTION
Presentation at Mobile App Europe Conference, Potsdam Germany October 2014.TRANSCRIPT
![Page 1: Mobile Test Automation using one API and one infrastructure](https://reader030.vdocuments.mx/reader030/viewer/2022020115/54833c8eb47959e70c8b4a13/html5/thumbnails/1.jpg)
1
30.09.2014
MOBILE TEST AUTOMATION SELENIUM SELENDROID IOS-DRIVER
![Page 2: Mobile Test Automation using one API and one infrastructure](https://reader030.vdocuments.mx/reader030/viewer/2022020115/54833c8eb47959e70c8b4a13/html5/thumbnails/2.jpg)
2
AGENDA
● Welcome
● Selenium Crash Course
● ios-driver + Selendroid
● Building a cross platform infrastructure
![Page 3: Mobile Test Automation using one API and one infrastructure](https://reader030.vdocuments.mx/reader030/viewer/2022020115/54833c8eb47959e70c8b4a13/html5/thumbnails/3.jpg)
3
WHO AM I ? Gridfusion Software Solutions Michael Palotas Dipl. Ing. (FH) Nachrichtentechnik Email: [email protected] LinkedIn: http://ch.linkedin.com/in/michaelpalotas/ Xing: https://www.xing.com/profile/Michael_Palotas Twitter: @michael_palotas Kontakt: Gerbiweg 2 8853 Lachen SWITZERLAND Tel.: +41 79 6690708
Founder / Principal Consultant Gridfusion Software Solutions
Head of Productivity & Test Engineering eBay International
![Page 4: Mobile Test Automation using one API and one infrastructure](https://reader030.vdocuments.mx/reader030/viewer/2022020115/54833c8eb47959e70c8b4a13/html5/thumbnails/4.jpg)
4
WARM-UP
Why do you automate tests?
Which tests should be automated?
Who should automate?
What is different about mobile?
![Page 5: Mobile Test Automation using one API and one infrastructure](https://reader030.vdocuments.mx/reader030/viewer/2022020115/54833c8eb47959e70c8b4a13/html5/thumbnails/5.jpg)
5
DISCLAIMER
THIS IS NOT A SELENDROID OR IOS-DRIVER TRAINING
![Page 6: Mobile Test Automation using one API and one infrastructure](https://reader030.vdocuments.mx/reader030/viewer/2022020115/54833c8eb47959e70c8b4a13/html5/thumbnails/6.jpg)
6
MOBILE TEST AUTOMATION
Not as mature as web automation
Immature tools market
Tools are usually platform specific
Multi code base
![Page 7: Mobile Test Automation using one API and one infrastructure](https://reader030.vdocuments.mx/reader030/viewer/2022020115/54833c8eb47959e70c8b4a13/html5/thumbnails/7.jpg)
7
EMULATORS VS. DEVICES
What to test where?
![Page 8: Mobile Test Automation using one API and one infrastructure](https://reader030.vdocuments.mx/reader030/viewer/2022020115/54833c8eb47959e70c8b4a13/html5/thumbnails/8.jpg)
8
SAME AUTOMATION CODE BETWEEN PLATFORMS?
Sounds good first
but
Most apps are different between platforms
Different element locator strategy
Do reuse the helper functions
![Page 9: Mobile Test Automation using one API and one infrastructure](https://reader030.vdocuments.mx/reader030/viewer/2022020115/54833c8eb47959e70c8b4a13/html5/thumbnails/9.jpg)
9
TEST INFRASTRUCTURE
AUT
DB
API
Browsers Mobiles
![Page 10: Mobile Test Automation using one API and one infrastructure](https://reader030.vdocuments.mx/reader030/viewer/2022020115/54833c8eb47959e70c8b4a13/html5/thumbnails/10.jpg)
10
2. SELENIUM
![Page 11: Mobile Test Automation using one API and one infrastructure](https://reader030.vdocuments.mx/reader030/viewer/2022020115/54833c8eb47959e70c8b4a13/html5/thumbnails/11.jpg)
11
A LITTLE SELENIUM HISTORY
Selenium was so named because Huggins, dissatisfied with testing tools on the market, was seeking a name that would position the product as an alternative to Mercury Interactive QuickTest Professional commercial testing software. The name, Selenium, was selected because selenium mineral supplements serve as a cure for mercury poisoning, Huggins explained.
![Page 12: Mobile Test Automation using one API and one infrastructure](https://reader030.vdocuments.mx/reader030/viewer/2022020115/54833c8eb47959e70c8b4a13/html5/thumbnails/12.jpg)
12
WHAT IS SELENIUM?
SELENIUM AUTOMATES BROWSERS
THAT'S IT
... One more thing ...
Selenium is becoming a W3C standard: http://www.w3.org/TR/webdriver
![Page 13: Mobile Test Automation using one API and one infrastructure](https://reader030.vdocuments.mx/reader030/viewer/2022020115/54833c8eb47959e70c8b4a13/html5/thumbnails/13.jpg)
13
WHAT IS SELENIUM?
Protocol which describes user interactions
Supports most browsers
Supports most programming languages
![Page 14: Mobile Test Automation using one API and one infrastructure](https://reader030.vdocuments.mx/reader030/viewer/2022020115/54833c8eb47959e70c8b4a13/html5/thumbnails/14.jpg)
14
SELENIUM – WHAT IT IS NOT
a drag & drop tool
a network testing / monitoring tool
a performance testing tool
a reporting tool
a testcase management tool
![Page 15: Mobile Test Automation using one API and one infrastructure](https://reader030.vdocuments.mx/reader030/viewer/2022020115/54833c8eb47959e70c8b4a13/html5/thumbnails/15.jpg)
15
WHY OPEN SOURCE?
It is free (…)
Independent of 3rd parties
Faster innovation cycles
Motivated employees
Easier hiring
![Page 16: Mobile Test Automation using one API and one infrastructure](https://reader030.vdocuments.mx/reader030/viewer/2022020115/54833c8eb47959e70c8b4a13/html5/thumbnails/16.jpg)
16
THE SELENIUM „FLAVORS“
Selenium IDE Selenium Selenium GRID
Let’s forget about this one real quick
![Page 17: Mobile Test Automation using one API and one infrastructure](https://reader030.vdocuments.mx/reader030/viewer/2022020115/54833c8eb47959e70c8b4a13/html5/thumbnails/17.jpg)
17
5. WEBDRIVER PROTOCOL
![Page 18: Mobile Test Automation using one API and one infrastructure](https://reader030.vdocuments.mx/reader030/viewer/2022020115/54833c8eb47959e70c8b4a13/html5/thumbnails/18.jpg)
18
SELENIUM 2 / WEBDRIVER
JSON WIRE PROTOCOL
Client
Java
C#
Ruby
Python
Server
i.e. Selendroid, iOS-Driver
Server
Server
![Page 19: Mobile Test Automation using one API and one infrastructure](https://reader030.vdocuments.mx/reader030/viewer/2022020115/54833c8eb47959e70c8b4a13/html5/thumbnails/19.jpg)
19
SELENIUM CLIENT
Is seen as Selenium by the users
Generates HTTP request, which are received by the server
Is called by the test framework or the CI server
Supported languages: Java, C#, Python, Ruby, Perl, PHP, JS
![Page 20: Mobile Test Automation using one API and one infrastructure](https://reader030.vdocuments.mx/reader030/viewer/2022020115/54833c8eb47959e70c8b4a13/html5/thumbnails/20.jpg)
20
SELENIUM SERVER
Receives HTTP requests from server
Start and teardown of browser
Translates requests into browser specific commands
Communicates back to the client
![Page 21: Mobile Test Automation using one API and one infrastructure](https://reader030.vdocuments.mx/reader030/viewer/2022020115/54833c8eb47959e70c8b4a13/html5/thumbnails/21.jpg)
21
6. SELENIUM BASICS
![Page 22: Mobile Test Automation using one API and one infrastructure](https://reader030.vdocuments.mx/reader030/viewer/2022020115/54833c8eb47959e70c8b4a13/html5/thumbnails/22.jpg)
22
DOWNLOADS
- http://www.seleniumhq.org/
- http://selenium.googlecode.com/files/selenium-server-standalone-2.42.2.jar
- Maven example:
![Page 23: Mobile Test Automation using one API and one infrastructure](https://reader030.vdocuments.mx/reader030/viewer/2022020115/54833c8eb47959e70c8b4a13/html5/thumbnails/23.jpg)
23
DRIVER
Each browser has its own driver
Firefox driver is part of the standalone jar http://selenium.googlecode.com/files/selenium-server-standalone-2.42.2.jar
Chrome: https://code.google.com/p/selenium/wiki/ChromeDriver
Opera: https://code.google.com/p/selenium/wiki/OperaDriver
Internet Explorer: https://code.google.com/p/selenium/wiki/InternetExplorerDriver
![Page 24: Mobile Test Automation using one API and one infrastructure](https://reader030.vdocuments.mx/reader030/viewer/2022020115/54833c8eb47959e70c8b4a13/html5/thumbnails/24.jpg)
24
DRIVER
Each driver implements the JSON Wire Protocol
Driver interacts with the browser (or mobile)
CLIENT
SERVER JSON Wire Protocol
BROWSER
DRIVER
![Page 25: Mobile Test Automation using one API and one infrastructure](https://reader030.vdocuments.mx/reader030/viewer/2022020115/54833c8eb47959e70c8b4a13/html5/thumbnails/25.jpg)
25
OUR FIRST TEST
Open a Firefox Browser
Go to http://gridfusion.net
Close the browser @Test public void myFirstTest() { WebDriver driver = new FirefoxDriver(); driver.get("http://gridfusion.net"); driver.quit(); }
![Page 26: Mobile Test Automation using one API and one infrastructure](https://reader030.vdocuments.mx/reader030/viewer/2022020115/54833c8eb47959e70c8b4a13/html5/thumbnails/26.jpg)
26
DRIVER API
![Page 27: Mobile Test Automation using one API and one infrastructure](https://reader030.vdocuments.mx/reader030/viewer/2022020115/54833c8eb47959e70c8b4a13/html5/thumbnails/27.jpg)
27
PAGE TITLE
Open a Firefox browser
Go to http://gridfusion.net
Print the page title in the console
Close the browser
@Test public void pageTitleTest() { WebDriver driver = new FirefoxDriver(); driver.get("http://gridfusion.net"); String pageTitle = driver.getTitle(); System.out.println(pageTitle); driver.quit(); }
![Page 28: Mobile Test Automation using one API and one infrastructure](https://reader030.vdocuments.mx/reader030/viewer/2022020115/54833c8eb47959e70c8b4a13/html5/thumbnails/28.jpg)
28
ASSERTS
Open a Firefox Browser
Go to: http://gridfusion.net
Verify Page Title = GRIDFUSION.net – Home
Close the browser
![Page 29: Mobile Test Automation using one API and one infrastructure](https://reader030.vdocuments.mx/reader030/viewer/2022020115/54833c8eb47959e70c8b4a13/html5/thumbnails/29.jpg)
29
WEBELEMENT
Represents an HTML Element
Interactions on a page happen via WebElement
http://selenium.googlecode.com/svn/trunk/docs/api/java/org/openqa/selenium/WebElement.html
![Page 30: Mobile Test Automation using one API and one infrastructure](https://reader030.vdocuments.mx/reader030/viewer/2022020115/54833c8eb47959e70c8b4a13/html5/thumbnails/30.jpg)
30
LOCATORS
id
cssSelector
linkText
name
partialLinkText
tagName
xpath
driver.findElement(By.XYZ)
![Page 31: Mobile Test Automation using one API and one infrastructure](https://reader030.vdocuments.mx/reader030/viewer/2022020115/54833c8eb47959e70c8b4a13/html5/thumbnails/31.jpg)
31
7. REMOTE WEBDRIVER
![Page 32: Mobile Test Automation using one API and one infrastructure](https://reader030.vdocuments.mx/reader030/viewer/2022020115/54833c8eb47959e70c8b4a13/html5/thumbnails/32.jpg)
32
REMOTE WEBDRIVER
Decouples tests from browsers
Machine 1 Eclipse TestNG CI
Machine 2 Browser HTTP
WebDriver driver = new RemoteWebDriver(new URL("http://localhost:4444/wd/hub"), DesiredCapabilities);
![Page 33: Mobile Test Automation using one API and one infrastructure](https://reader030.vdocuments.mx/reader030/viewer/2022020115/54833c8eb47959e70c8b4a13/html5/thumbnails/33.jpg)
33
DESIRED CAPABILITIES - BROWSER
DesiredCapabilities capability = new DesiredCapabilities(); capability.setBrowserName(“firefox”);
https://code.google.com/p/selenium/wiki/DesiredCapabilities
![Page 34: Mobile Test Automation using one API and one infrastructure](https://reader030.vdocuments.mx/reader030/viewer/2022020115/54833c8eb47959e70c8b4a13/html5/thumbnails/34.jpg)
34
REMOTEWEBDRIVER
● Start a selenium server:
● java –jar selenium-server-standalone-2.42.2.jar
● Use RemoteWebDriver and set DesiredCapabilities to Firefox
● Open a Firefox browser
● Go to: http://gridfusion.net
● Close the browser
@Test public void remoteWebdriverFireFoxTest() throws MalformedURLException { DesiredCapabilities capability = DesiredCapabilities.firefox(); WebDriver driver = new RemoteWebDriver(new URL("http://localhost:4444/wd/hub"), capability); driver.get("http://gridfusion.net"); driver.quit(); }
![Page 35: Mobile Test Automation using one API and one infrastructure](https://reader030.vdocuments.mx/reader030/viewer/2022020115/54833c8eb47959e70c8b4a13/html5/thumbnails/35.jpg)
35
8. SELENIUM GRID
![Page 36: Mobile Test Automation using one API and one infrastructure](https://reader030.vdocuments.mx/reader030/viewer/2022020115/54833c8eb47959e70c8b4a13/html5/thumbnails/36.jpg)
36
WHY SELENIUM GRID?
Environment Management & Control
Scaling
Parallel execution of tests
Reduction of execution times
Crossover tests (web, mobile)
![Page 37: Mobile Test Automation using one API and one infrastructure](https://reader030.vdocuments.mx/reader030/viewer/2022020115/54833c8eb47959e70c8b4a13/html5/thumbnails/37.jpg)
37
SELENIUM GRID
TEST TEST TEST TEST
SEQUENTIAL EXECUTION
TIME
n
TEST TEST TEST TEST
TEST TEST TEST TEST
PARALLEL EXECUTION
TEST TEST TEST TEST
TEST TEST TEST TEST
TIME
n
![Page 38: Mobile Test Automation using one API and one infrastructure](https://reader030.vdocuments.mx/reader030/viewer/2022020115/54833c8eb47959e70c8b4a13/html5/thumbnails/38.jpg)
38
SCALING – SELENIUM GRID
CI
DEV
….
SELENIUM GRID HUB
IOS ANDROID
LINUX
WINDOWS
OSX
![Page 39: Mobile Test Automation using one API and one infrastructure](https://reader030.vdocuments.mx/reader030/viewer/2022020115/54833c8eb47959e70c8b4a13/html5/thumbnails/39.jpg)
39
1. STEP– START THE GRID HUB
Open a new terminal window
Start the Selenium GRID hub by typing:
java -jar selenium-server-standalone-2.42.jar -role hub
Enter http://localhost:4444/grid/console into the browser
![Page 40: Mobile Test Automation using one API and one infrastructure](https://reader030.vdocuments.mx/reader030/viewer/2022020115/54833c8eb47959e70c8b4a13/html5/thumbnails/40.jpg)
40
2. STEP– REGISTER A NODE
Open a second terminal window
Start and register a Selenium node by entering:
java -jar selenium-server-standalone-x.y.z.jar –role wd -hub http://localhost:4444/grid/register
![Page 41: Mobile Test Automation using one API and one infrastructure](https://reader030.vdocuments.mx/reader030/viewer/2022020115/54833c8eb47959e70c8b4a13/html5/thumbnails/41.jpg)
41
SELENIUM NODE – STANDARD CONFIG
- Go to: http://localhost:4444/grid/console
Standard Configuration:
5 Firefox
5 Chrome
1 Internet Explorer
![Page 42: Mobile Test Automation using one API and one infrastructure](https://reader030.vdocuments.mx/reader030/viewer/2022020115/54833c8eb47959e70c8b4a13/html5/thumbnails/42.jpg)
42
SCREENSHOTS
![Page 43: Mobile Test Automation using one API and one infrastructure](https://reader030.vdocuments.mx/reader030/viewer/2022020115/54833c8eb47959e70c8b4a13/html5/thumbnails/43.jpg)
43
10. REPORTING
![Page 44: Mobile Test Automation using one API and one infrastructure](https://reader030.vdocuments.mx/reader030/viewer/2022020115/54833c8eb47959e70c8b4a13/html5/thumbnails/44.jpg)
44
STANDARD REPORTS
- TestNG reports are put into: **/test-output
- Look for: emailable-report.html
![Page 45: Mobile Test Automation using one API and one infrastructure](https://reader030.vdocuments.mx/reader030/viewer/2022020115/54833c8eb47959e70c8b4a13/html5/thumbnails/45.jpg)
45
CUSTOM REPORTING
- By calling Reporter.log(“your log message”), you can add additional information to the report
![Page 46: Mobile Test Automation using one API and one infrastructure](https://reader030.vdocuments.mx/reader030/viewer/2022020115/54833c8eb47959e70c8b4a13/html5/thumbnails/46.jpg)
46
SCREENSHOTS
- Screenshots can also be placed directly into the report
![Page 47: Mobile Test Automation using one API and one infrastructure](https://reader030.vdocuments.mx/reader030/viewer/2022020115/54833c8eb47959e70c8b4a13/html5/thumbnails/47.jpg)
47
12. MOBILE AUTOMATION
![Page 48: Mobile Test Automation using one API and one infrastructure](https://reader030.vdocuments.mx/reader030/viewer/2022020115/54833c8eb47959e70c8b4a13/html5/thumbnails/48.jpg)
48
SELENIUM 2 / WEBDRIVER
JSON WIRE PROTOCOL
Client
Java
C#
Ruby
Python
Server
i.e. Selendroid, iOS-Driver
Server
Server
![Page 49: Mobile Test Automation using one API and one infrastructure](https://reader030.vdocuments.mx/reader030/viewer/2022020115/54833c8eb47959e70c8b4a13/html5/thumbnails/49.jpg)
49
(SOME) MOBILE AUTOMATION REQUIREMENTS
* Reuse of the existing Selenium infrastructure for the web
* Implementation of the Selenium protocol (JSON wire protocol)
* The application under test (aut) should not need to be modified
* Support for emulators/simulators as well as real devices
* Parallel execution of tests in a Selenium Grid
* Management of multiple applications, versions, languages
* Support for runtime inspection for the app
* Hybrid app support
* No jailbreaking of device required
![Page 50: Mobile Test Automation using one API and one infrastructure](https://reader030.vdocuments.mx/reader030/viewer/2022020115/54833c8eb47959e70c8b4a13/html5/thumbnails/50.jpg)
50
IOS-DRIVER + SELENDROID
IOS: http://ios-driver.github.io/ios-driver/index.html
ANDROID: http://selendroid.io/
Both projects implement the Webdriver API (JSON Wire Protocol)
![Page 51: Mobile Test Automation using one API and one infrastructure](https://reader030.vdocuments.mx/reader030/viewer/2022020115/54833c8eb47959e70c8b4a13/html5/thumbnails/51.jpg)
51
ANDROID: MOBILE WEB
![Page 52: Mobile Test Automation using one API and one infrastructure](https://reader030.vdocuments.mx/reader030/viewer/2022020115/54833c8eb47959e70c8b4a13/html5/thumbnails/52.jpg)
52
ANDROID: NATIVE APP
![Page 53: Mobile Test Automation using one API and one infrastructure](https://reader030.vdocuments.mx/reader030/viewer/2022020115/54833c8eb47959e70c8b4a13/html5/thumbnails/53.jpg)
53
IOS: MOBILE WEB
![Page 54: Mobile Test Automation using one API and one infrastructure](https://reader030.vdocuments.mx/reader030/viewer/2022020115/54833c8eb47959e70c8b4a13/html5/thumbnails/54.jpg)
54
WRITE ONCE RUN EVERYWHERE
![Page 55: Mobile Test Automation using one API and one infrastructure](https://reader030.vdocuments.mx/reader030/viewer/2022020115/54833c8eb47959e70c8b4a13/html5/thumbnails/55.jpg)
55
WRITE ONCE RUN EVERYWHERE
![Page 56: Mobile Test Automation using one API and one infrastructure](https://reader030.vdocuments.mx/reader030/viewer/2022020115/54833c8eb47959e70c8b4a13/html5/thumbnails/56.jpg)
56
INSPECTOR
![Page 57: Mobile Test Automation using one API and one infrastructure](https://reader030.vdocuments.mx/reader030/viewer/2022020115/54833c8eb47959e70c8b4a13/html5/thumbnails/57.jpg)
57
SAUCELABS CLOUD
![Page 58: Mobile Test Automation using one API and one infrastructure](https://reader030.vdocuments.mx/reader030/viewer/2022020115/54833c8eb47959e70c8b4a13/html5/thumbnails/58.jpg)
58
WHAT HAVE YOU LEARNED TODAY?
![Page 59: Mobile Test Automation using one API and one infrastructure](https://reader030.vdocuments.mx/reader030/viewer/2022020115/54833c8eb47959e70c8b4a13/html5/thumbnails/59.jpg)
59
THANK YOU