2. AGENDA
● Welcome
● Selenium Crash Course
● ios-driver + Selendroid
● Building a cross platform infrastructure
2
3. WHO AM I ?
3
Gridfusion Software Solutions
Michael Palotas
Dipl. Ing. (FH) Nachrichtentechnik
Email: michael.palotas@gridfusion.net
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
4. WARM-UP
4
Why do you automate tests?
Which tests should be automated?
Who should automate?
What is different about mobile?
8. SAME AUTOMATION CODE BETWEEN
PLATFORMS?
8
Sounds good first
but
Most apps are different between platforms
Different element locator strategy
Do reuse the helper functions
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.
11
12. WHAT IS SELENIUM?
12
SELENIUM AUTOMATES BROWSERS
THAT'S IT
... One more thing ...
Selenium is becoming a W3C standard: http://www.w3.org/TR/webdriver
13. WHAT IS SELENIUM?
13
Protocol which describes user interactions
Supports most browsers
Supports most programming languages
14. SELENIUM – WHAT IT IS NOT
14
a drag & drop tool
a network testing / monitoring tool
a performance testing tool
a reporting tool
a testcase management tool
15. WHY OPEN SOURCE?
15
It is free (…)
Independent of 3rd parties
Faster innovation cycles
Motivated employees
Easier hiring
16. THE SELENIUM „FLAVORS“
16
Selenium IDE
Selenium
Selenium GRID
Let’s forget about this one real quick
18. SELENIUM 2 / WEBDRIVER
18
JSON WIRE
PROTOCOL
Client
Java
C#
Ruby
Python
Server
Server
Server
i.e. Selendroid, iOS-Driver
19. SELENIUM CLIENT
19
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
20. SELENIUM SERVER
20
Receives HTTP requests from server
Start and teardown of browser
Translates requests into browser specific
commands
Communicates back to the client
23. DRIVER
23
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
24. DRIVER
Each driver implements the JSON Wire Protocol
Driver interacts with the browser (or mobile)
CLIENT
SERVER
24
JSON Wire Protocol
BROWSER
DRIVER
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();
}
25
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();
}
27
28. ASSERTS
Open a Firefox Browser
Go to: http://gridfusion.net
Verify Page Title = GRIDFUSION.net – Home
Close the browser
28
29. WEBELEMENT
29
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
30. LOCATORS
id
cssSelector
linkText
name
partialLinkText
tagName
xpath
30
driver.findElement(By.XYZ)
34. REMOTEWEBDRIVER
● Start a selenium server:
34
● 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();
}
36. WHY SELENIUM GRID?
36
Environment Management & Control
Scaling
Parallel execution of tests
Reduction of execution times
Crossover tests (web, mobile)
37. SELENIUM GRID
37
SEQUENTIAL EXECUTION
TEST TEST TEST TEST
TIME
n
PARALLEL EXECUTION
TEST TEST TEST TEST
TEST TEST TEST TEST
TEST TEST TEST TEST
TEST TEST TEST TEST
TIME
n
38. SCALING – SELENIUM GRID
38
DEV
CI
….
SELENIUM GRID
HUB
IOS ANDROID
WINDOWS
LINUX
OSX
39. 1. STEP– START THE GRID HUB
39
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
40. 2. STEP– REGISTER A NODE
40
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
41. SELENIUM NODE – STANDARD CONFIG
- Go to: http://localhost:4444/grid/console
Standard Configuration:
5 Firefox
5 Chrome
1 Internet Explorer
41
48. SELENIUM 2 / WEBDRIVER
48
JSON WIRE
PROTOCOL
Client
Java
C#
Ruby
Python
Server
Server
Server
i.e. Selendroid, iOS-Driver
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
49
50. IOS-DRIVER + SELENDROID
50
IOS:
http://ios-driver.github.io/ios-driver/index.html
ANDROID:
http://selendroid.io/
Both projects implement the Webdriver API (JSON
Wire Protocol)