Dieses OpenTuesday-Referat zeigt den Einsatz der Selenium-Toolfamilie in einem hochskalierbaren Web- und Mobile-Umfeld anhand von praktischen Beispielen. Ebenso werden die Vorteile von Open Source Tools in Bezug auf Konkurrenzfähigkeit und Innovationskraft von Unternehmen aufgezeigt.
2. TODAY'S TOPICS
● A few thoughts on automation
● Selenium Tool Family Overview
– Selenium History
– IDE
– WebDriver
– GRID
● Demo(s)
● Mobile and Selenium
● Why Open Source ?
2 GRIDFUSION.NET
3. WHO AM I ?
MICHAEL PALOTAS
Dipl. Ing. (FH) Nachrichtentechnik
michael.palotas@gridfusion.net
http://gridfusion.net
http://ch.linkedin.com/in/michaelpalotas
http://www.xing.com/profile/Michael_Palotas
eBay GRIDFUSION
Head of Quality Engineering Europe Founder & Principal Consultant
3 GRIDFUSION.NET
5. A FEW THOUGHTS ON TEST AUTOMATION
● Manual testing is still very important
● E2E tests are expensive, so keep them to the minimum
● Automation is software development
● Be careful with record & playback tools
● Automate the repetitive tasks (regression)
● Build testability into your product
● ROI...
● More at http://gridfusion.net/thoughtsonautomation.html
5 GRIDFUSION.NET
6. SELENIUM AUTOMATES BROWSERS
THAT'S IT
... kind of
Selenium is becoming a W3C standard: http://www.w3.org/TR/webdriver
7 GRIDFUSION.NET
8. SELENIUM IDE
What it is:
– First Selenium experience for many people
– Firefox add-on
– Record & playback solution
– Not maintainable
What it is for:
– Quick reproduction of scenarios & bugs
– Products with few testcases & low change frequency
– Help to write the „real tests“
– Find ID's / XPATH etc.
9 GRIDFUSION.NET
9. SELENIUM (WEBDRIVER)
What it is :
– Web testing tool
– Highly successful open source project
– Stable
Technical :
– Protocol describing the user interactions
– Supports most browser implementations
– Support for most common programming languages
11 GRIDFUSION.NET
10. WHAT IT IS NOT
- a drag & drop tool
- a network testing / monitoring tool
- a performance testing tool
- a reporting tool
12 GRIDFUSION.NET
11. 2 PIECES
client json wire protocol server
13 GRIDFUSION.NET
12. CLIENT
● What testers "see" as selenium
● It doesn't "do" anything except generates Http requests
that will be handled by the server
● It is the part that will be called :
– By the test framework
– By the CI server
● Officially supported languages: java, c#, python,ruby
● Not officially supported : perl, php, js
14 GRIDFUSION.NET
13. SERVER
● Where all the action happens
● Where the contributors spend their time
● Drives the browser under test
● Supported by the Selenium team: IE, Firefox, Safari
● Supported by vendors: Chrome, Opera
15 GRIDFUSION.NET
14. BASIC ARCHITECTURE
Language
Bindings
SELENIUM Server
Client
TESTS (& BROWSER
GRID)
16 GRIDFUSION.NET
15. TESTS
Tests are java executable code and can be run:
– Manually from a personal machine, using an
IDE
– Automatically from a continuous
integration server
17 GRIDFUSION.NET
16. TEST EXAMPLE
@Test
public void localBrowserTest() throws MalformedURLException{
System.out.println("starting test");
DesiredCapabilities capability = DesiredCapabilities.chrome();
WebDriver driver = new RemoteWebDriver(new URL("http://localhost:4444/wd/hub"), capability);
driver.get("http://www.digicomp.ch");
WebElement searchBox = driver.findElement(By.id("q"));
searchBox.sendKeys("Selenium");
WebElement go = driver.findElement(By.className("submitsearch"));
go.click();
Assert.assertEquals(driver.getTitle(), "Digicomp");
System.out.println("Page Title: " + driver.getTitle());
driver.quit();
}
18 GRIDFUSION.NET
17. GRID
● Scale
● Run tests in parallel
● Reduce test execution times
● Crossover Tests (Web, Mobile, Desktop)
19 GRIDFUSION.NET
18. SELENIUM GRID
SEQUENTIAL EXECUTION PARALLEL EXECUTION
TEST TEST TEST TEST
n n
TEST TEST TEST TEST
TEST TEST TEST TEST
TEST TEST TEST TEST TEST TEST TEST TEST
TIME TIME
20 GRIDFUSION.NET
19. GRID
D IE
NODE 1
S
CI (WIN)
D FF
D OPERA
GRID NODE 2
CLIENT S
HUB (LINUX)
D CHROME
.
.
CLIENT .
NODE n S
21 GRIDFUSION.NET
20. PUTTING IT INTO ACTION (WITHOUT GRID)
Start the Selenium Server
– java -jar selenium-server-standalone-x.y.z.jar
DONE
Language
Bindings
Client
BROWSER
TESTS SELENIUM Server
22 GRIDFUSION.NET
21. PUTTING IT INTO ACTION WITH GRID
Start the Selenium GRID hub
– Java -jar selenium-server-standalone-x.y.z.jar -role hub
– Check: http://ipaddress:4444/grid/console
Start a Selenium Node & register with the hub
– java -jar selenium-server-standalone-x.y.z.jar -role node -hub
http://ipaddress:4444/grid/register
OR to specify Browser / OS
– java -jar selenium-server-standalone-x.y.z.jar -role node -hub
http://ipadress:4444/grid/register -browser
browserName=firefox,maxInstances=4,platform=LINUX
Chrome
Language
Bindings
GRID
Client
TESTS NODE Server
HUB FF
24 GRIDFUSION.NET
22. MOBILE
● Mobile automation should be compatible /
similar to Web automation
● Mobile Web automation is less of a problem
● Native App automation is more difficult
● Mobile Web: android-driver / iphone-driver
● Native apps: calabash-driver, ios-driver
26 GRIDFUSION.NET
23. IOS-DRIVER
● Implements the JSON wire protocol
● Runs on emulators and devices
● Can be run as a regular node in a Selenium Grid
● No need to change the source
● No need to jailbreak the device
● No ios-driver app to install on the phone
● http://freynaud.github.com/ios-driver/
27 GRIDFUSION.NET
24. WHY ALL IN ONE GRID ?
● Web and mobile are converging
● Users are moving between devices (i.e. Web
(in the office) -> Android Phone (on the train)
-> iPad (at home on the couch)
● Need to ensure consistent user experience
and functionality
28 GRIDFUSION.NET
26. WHY OPEN SOURCE?
● Accelerator for innovation
● Independence from vendors
● Worldwide support and contributions
● It is free (...kind of)
● Motivator for employees
● External recognition for employees
33 GRIDFUSION.NET