OpenTuesday: Die Selenium-Toolfamilie und ihr Einsatz im Web- und Mobile-Automatisierungsumfeld

28
GRIDFUSION.NET SELENIUM Michael Palotas, GRIDFUSION Software Solutions February 5 2013

Transcript of OpenTuesday: Die Selenium-Toolfamilie und ihr Einsatz im Web- und Mobile-Automatisierungsumfeld

GRIDFUSION.NET

SELENIUM

Michael Palotas, GRIDFUSION Software Solutions February 5 2013

GRIDFUSION.NET2

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 ?

GRIDFUSION.NET3

WHO AM I ?

eBay Head of Quality Engineering Europe

GRIDFUSION Founder & Principal Consultant

MICHAEL PALOTAS

Dipl. Ing. (FH) Nachrichtentechnik

[email protected]

http://gridfusion.net

http://ch.linkedin.com/in/michaelpalotas

http://www.xing.com/profile/Michael_Palotas

GRIDFUSION.NET4

SELENIUM VS. QTP JOB TRENDS

GRIDFUSION.NET5

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

GRIDFUSION.NET7

SELENIUM AUTOMATES BROWSERS

THAT'S IT

... kind of

Selenium is becoming a W3C standard: http://www.w3.org/TR/webdriver

GRIDFUSION.NET8

SELENIUM FLAVORS

Selenium IDE

Selenium RC(deprecated)

WebDriver

Selenium GRID

GRIDFUSION.NET9

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.

GRIDFUSION.NET11

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

GRIDFUSION.NET12

WHAT IT IS NOT

- a drag & drop tool

- a network testing / monitoring tool

- a performance testing tool

- a reporting tool

GRIDFUSION.NET13

2 PIECES

client serverjson wire protocol

GRIDFUSION.NET14

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

GRIDFUSION.NET15

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

GRIDFUSION.NET16

BASIC ARCHITECTURE

TESTSSELENIUM Server

(& GRID)

BROWSER

Clie

ntLa

ngu

age

Bin

ding

s

GRIDFUSION.NET17

TESTS

Tests are java executable code and can be run:

– Manually from a personal machine, using an IDE

– Automatically from a continuous integration server

GRIDFUSION.NET18

TEST EXAMPLE

@Testpublic 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();

}

GRIDFUSION.NET19

GRID

● Scale● Run tests in parallel ● Reduce test execution times● Crossover Tests (Web, Mobile, Desktop)

GRIDFUSION.NET20

SELENIUM GRID

TEST TEST TEST TEST

SEQUENTIAL EXECUTION

TIME

n

TEST TEST TEST TEST

TEST TEST TESTTEST

PARALLEL EXECUTION

TEST TEST TESTTEST

TEST TEST TESTTEST

TIME

n

GRIDFUSION.NET21

GRID

CLIENTGRIDHUB

NODE 1(WIN)

NODE 2(LINUX)

NODE n

IE

FF

OPERA

CHROME

.

.

.

S

S

S

D

D

D

D

CLIENT

CI

GRIDFUSION.NET22

PUTTING IT INTO ACTION (WITHOUT GRID)

Start the Selenium Server– java -jar selenium-server-standalone-x.y.z.jar

DONE

TESTS SELENIUM ServerBROWSER

Clie

ntLa

ngu

age

Bin

ding

s

GRIDFUSION.NET24

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

TESTSGRIDHUB

NODEChrome

FFServer

Clie

ntL

ang

uag

eB

ind

ing

s

GRIDFUSION.NET26

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

GRIDFUSION.NET27

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/

GRIDFUSION.NET28

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

GRIDFUSION.NET31

PAGE OBJECTS

•http://code.google.com/p/selenium/wiki/PageObjects

•Page objects model the pages and page interactions

•Reduce code duplication

•Reduce maintenance effort

•Easy international support

•Public methods represent the service of a page

GRIDFUSION.NET33

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

GRIDFUSION.NET35

USEFUL LINKS

● Selenium Homepage: http://seleniumhq.org/

● Selenium Download: http://seleniumhq.org/download/

● Wiki: http://code.google.com/p/selenium/w/list

GRIDFUSION.NET36

THANK YOU!

QUESTIONS?

COMMENTS?

CONTACT:

GRIDFUSION, MICHAEL PALOTAS

GERBIWEG 2, 8853 LACHEN, Tel.: +41 44 577 1555

[email protected]

http://gridfusion.net