3. ● 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
4. Selenium to UI-Testing is like..
Power Steering & Automatic Transmission is to Driving
I'm
not making you
coffee!
5. Unit Tests: Same language, Easy setup. Synchronous.
// Setup
Account account = new Account();
// Stimuli e.g. click, setting text, XHR
account.login( "borg", "resistance is futile" );
// Validation
assert( account.isLoggedIn(), true );
E2E vs. Unit - same same but different
7. ● Synchronous?
● Same language?
● Easy setup?
○ Where are the browsers running?
○ Who's in charge of keeping them alive?
E2E is hard!
8. Expected: Actual:
Cowabunga
It gets worse.. I shit you not!
Cowabunga Cowabungaz-index
Cowabungasize
CowabungaThe Flying Pony
Cowabung
a
Over here!
Blur, Focus, ….
CSS
HTML
JS Event
16. // setup
WebDriver driver = new Chrome();
driver.get("http://www.google.com");
// stimuli
driver.findElement( By.id("user") ).sendKeys("mel brooks");
driver.findElement( By.id("password") ).sendKeys("12345");
driver.findElement( By.id("submit") ).submit();
// assertion
assert(driver.getTitle(), "That's the kind of thing an idiot would have on his luggage!");
// tear down
driver.quit();
Example
23. 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
24. // setup
WebDriver driver = new Chrome();
driver.get("http://www.google.com");
// stimuli
driver.findElement( By.id("user") ).sendKeys("mel brooks");
driver.findElement( By.id("password") ).sendKeys("12345");
driver.findElement( By.id("submit") ).submit();
// assertion
assert(driver.getTitle(), "That's the kind of thing an idiot would have on his luggage!");
// tear down
driver.quit();
Example
Simon
says no!
@Test
void loginTest () {