test automation & seleniun by oren rubin

36
Test Automation & Selenium Oren Rubin CEO, Testim.io

Upload: oren-rubin

Post on 03-Jul-2015

595 views

Category:

Software


3 download

DESCRIPTION

Overview explanation on End to End Test Automation with focus UI Testing (and Selenium).

TRANSCRIPT

Page 1: Test automation & Seleniun by oren rubin

Test Automation & Selenium

Oren RubinCEO, Testim.io

Page 2: Test automation & Seleniun by oren rubin

Oren Rubin

Page 3: Test automation & Seleniun by oren rubin

● Why Unit Tests aren't enough?

● Writing Unit Tests !== Writing E2E Tests

● Meet Selenium

● Best practices & Design Patterns

● Selenium Grid

● UI Validations

● Record / Playback

Today's Menu

Page 4: Test automation & Seleniun by oren rubin

Selenium to UI-Testing is like..

Power Steering & Automatic Transmission is to Driving

I'm not making you

coffee!

Page 5: Test automation & Seleniun by oren rubin

Unit Tests: Same language, Easy setup. Synchronous.

// Setup Account account = new Account();

// Stimuli e.g. click, setting text, XHRaccount.login( "borg", "resistance is futile" );

// Validation assert( account.isLoggedIn(), true );

E2E vs. Unit - same same but different

Page 6: Test automation & Seleniun by oren rubin

E2E is

the real

SHIT!

Page 7: Test automation & Seleniun by oren rubin

● Synchronous?

● Same language?

● Easy setup?

○ Where are the browsers running?

○ Who's in charge of keeping them alive?

E2E is hard!

Page 8: Test automation & Seleniun by oren rubin

Expected: Actual:

Cowabunga

It gets worse.. I shit you not!

Cowabunga Cowabungaz-index

Cowabungasize

CowabungaThe Flying Pony

Cowabunga

Over here!

Blur, Focus, ….

CSS

HTML

JS Event

Page 9: Test automation & Seleniun by oren rubin

One browser.. you wish!

* What about responsive design?!

Page 10: Test automation & Seleniun by oren rubin

Which language do you prefer?

Test Language?

Page 11: Test automation & Seleniun by oren rubin

Meet Selenium

Page 12: Test automation & Seleniun by oren rubin

Why the name Selenium?

Page 13: Test automation & Seleniun by oren rubin

Selenium 1 - JS based

Selenium 2 - WebDriver & WebElements

Selenium 3 - Mobile

Past, Present, and Future

Page 14: Test automation & Seleniun by oren rubin

Google Trends - Same for Jobs

Page 15: Test automation & Seleniun by oren rubin

Example - la login

Page 16: Test automation & Seleniun by oren rubin

// setupWebDriver driver = new Chrome();driver.get("http://www.google.com");

// stimulidriver.findElement( By.id("user") ).sendKeys("mel brooks");driver.findElement( By.id("password") ).sendKeys("12345");driver.findElement( By.id("submit") ).submit();

// assertionassert(driver.getTitle(), "That's the kind of thing an idiot would have on his luggage!");

// tear downdriver.quit();

Example

Page 17: Test automation & Seleniun by oren rubin

Architecture

?Can anyone suggest a good architecture?

...

...

Page 18: Test automation & Seleniun by oren rubin

One (W3C) Standard to rule them all!

https://code.google.com/p/selenium/wiki/JsonWireProtocol http://www.w3.org/TR/webdriver/

Page 19: Test automation & Seleniun by oren rubin

HTTP as a universal language

? The WireProtocol

SDK Driver

Page 20: Test automation & Seleniun by oren rubin

Closer look

new Chrome(); chromedriver.exe

BrowserHTTP Request

localhost:4444/click

driver = new Chrome();...submitBtn.click();

driver

note: don't forget to frequently update chromedriver.exe

Page 21: Test automation & Seleniun by oren rubin

Now for Firefox

new Firefox(); webdriver.xpi

BrowserHTTP Request

localhost:4444/click

driver

driver = new Firefox();...submitBtn.click();

Page 22: Test automation & Seleniun by oren rubin

Let's improveloginChromeTest () { driver = new Chrome(); loginTest(driver);}

loginFirefoxTest () { driver = new Firefox(); loginTest(driver);}

loginTest (driver) { driver.findElement( By.id("user") ).sendKeys("mel brooks"); driver.findElement( By.id("password") ).sendKeys("12345"); driver.findElement( By.id("submit") ).submit();}

Page 23: Test automation & Seleniun by oren rubin

Page Objects

A Design Pattern.

Provides a programmatic API to drive and interrogate a UI

Best Practices & Design Patterns

http://www.slideshare.net/orenrubin/page-objects-presentation-selenium-conference-2014-38767492

Page 24: Test automation & Seleniun by oren rubin

// setupWebDriver driver = new Chrome();driver.get("http://www.google.com");

// stimulidriver.findElement( By.id("user") ).sendKeys("mel brooks");driver.findElement( By.id("password") ).sendKeys("12345");driver.findElement( By.id("submit") ).submit();

// assertionassert(driver.getTitle(), "That's the kind of thing an idiot would have on his luggage!");

// tear downdriver.quit();

ExampleSimon says no!

@Testvoid loginTest () {

Page 25: Test automation & Seleniun by oren rubin

Test Automation Architecture

Link to "Page Objects Done Right" Presentation

Page 26: Test automation & Seleniun by oren rubin

Selenium Grid

● Concurrency

● Multiple Platforms

Page 27: Test automation & Seleniun by oren rubin

Remember this?

new Chrome(); chromedriver.exe

BrowserHTTP Request

localhost:8989/click

driver = new Chrome();...submitBtn.click();

driver

Page 28: Test automation & Seleniun by oren rubin

What we want

new Chrome(); chromedriver.exe

BrowserHTTP Request

<some-ip>:8989/click

driver = new Chrome();...submitBtn.click();

driver

computer 1 computer 2

Page 29: Test automation & Seleniun by oren rubin

Selenium Grid

java -jar selenium.jar -port 4444 -role hub

selenium hub

Node 0 on 10.0

Page 30: Test automation & Seleniun by oren rubin

Selenium Grid

Node 1 on 10.1

Node 2 on 10.2

selenium node

java -jar selenium.jar -role webdriver -browser firefox -hubHost 10.0 –port 8989

java -jar selenium.jar -port 4444 -role hub

selenium node

java -jar selenium.jar -role webdriver -browser chrome -hubHost 10.0 –port 8989

selenium hub

Node 0 on 10.0

chromedriver.exe

firefox-webdriver.dpi

Page 31: Test automation & Seleniun by oren rubin

Selenium Grid

new Chrome();

BrowserHTTP Request

10.0:4444/chrome

hub = new URL("10.0:4444/wd/hub")cap = new Capabilities ("chrome", "v3", "windows")driver = new RemoteWebDriver( hub, cap );...

driver

my computer / CI server

Node 1 on 10.1

Node 2 on 10.2

selenium node

java -jar selenium.jar -role webdriver -hubHost 10.1 –port 8989

java -jar selenium.jar -port 4444 -role hub

selenium node

java -jar selenium.jar -role webdriver -hubHost 10.1 –port 8989

selenium hub

Node 0 on 10.0

HTTP Request

10.2:8989/chrome

chromedriver.exe

firefox-webdriver.dpi

Page 32: Test automation & Seleniun by oren rubin

Selenium Grid

new Chrome();

BrowserHTTP Request

10.0:4444/click

driver = ...

submitBtn = driver.find(By.id("submit"));submitBtn.click();

driver

my computer / CI server

Node 1 on 10.1

Node 2 on 10.2

selenium node

java -jar selenium.jar -role webdriver -hubHost 10.1 –port 8989

java -jar selenium.jar -port 4444 -role hub

selenium node

java -jar selenium.jar -role webdriver -hubHost 10.1 –port 8989

selenium hub

Node 0 on 10.0

HTTP Request

10.2:8989/click

chromedriver.exe

firefox-webdriver.dpi

Page 33: Test automation & Seleniun by oren rubin

Browsers in the cloudSelenium Grid as a Service

SaaS Open source

Page 34: Test automation & Seleniun by oren rubin

Spot the differences

Page 35: Test automation & Seleniun by oren rubin

UI Verification - Applitools eyeOne image is worth a 1000 assertions

Page 36: Test automation & Seleniun by oren rubin

Oren Rubin

Testim.io

[email protected]

Thank you!