Slide 1

Slide 1 text

CROSS BROWSER TESTING WITH SELENIUM MARCO PICELLO [email protected]

Slide 2

Slide 2 text

WHO AM I Marco Picello J2EE consultant Automation lover

Slide 3

Slide 3 text

AGENDA What is Selenium webdriver Good parts Bad parts Q&A

Slide 4

Slide 4 text

TODAY FUNCTIONAL TEST OF WEB APP Multiple browser Multiple display dimensions (a.k.a. Responsive design) Mobile app Time consuming Error prone Booring!!!!

Slide 5

Slide 5 text

BENEFITS OF AUTOMATIC FUNCTIONAL TESTING OF WEB APPLICATION Frequent regression testing Rapid feedback to developers Form of documentation for test cases, automatically generated, and up to date Custom defect reporting Finding defect missing by manual testing

Slide 6

Slide 6 text

SELENIUM Created by Thoughworks in 2007 Now opensource Set of components for automated testing Custom defect reporting Used by Thoughworks, Facebook, Google, and many others

Slide 7

Slide 7 text

SELENIUM COMPONENTS Selenium IDE Selenium WebDriver Selenium Grid

Slide 8

Slide 8 text

OK, SO WHAT CAN I DO WITH WEBDRIVER? Open a web page in a real browser Change browser dimensions Interact with browser: click on link, upload file, fill input field, click on checkbox, etc Take web page's screenshots Get the page source

Slide 9

Slide 9 text

SELENIUM WEBDRIVER OVERVIEW

Slide 10

Slide 10 text

JSON WIRE PROTOCOL

Slide 11

Slide 11 text

SUPPORTED BROWSERS Internet Explorer 6, 7, 8, 9, 10 FireFox Safari Opera HtmlUnit phantomjs Android (with Selendroid or appium) iOS (with ios-driver or appium)

Slide 12

Slide 12 text

SELENIUM WEBDRIVER CLIENT, DEVELOPED OFFICIALLY Java C# Ruby Python Javascript (Node)

Slide 13

Slide 13 text

SELENIUM WEBDRIVER CLIENT, DEVELOPED NOT OFFICIALLY PHP Perl Objective-C R Dart TCL Go

Slide 14

Slide 14 text

HELLO WORLD SELENIUM // Create a new instance of the Firefox driver WebDriver driver = new FirefoxDriver(); // And now use this to visit Google driver.get("http://www.google.com"); // Find the text input element by its name WebElement element = driver.findElement(By.name("q")); // Enter something to search for element.sendKeys("Cheese!"); // Now submit the form. WebDriver will find the form for us from the element element.submit(); //Close the browser driver.quit();

Slide 15

Slide 15 text

GOOD PARTS Mature project (current version is 2.44.0) Cross browser Language indipendent

Slide 16

Slide 16 text

BAD PARTS!!! Tests are slow Flaky test It's just a driver!!! You'll write lots of boilerplate code

Slide 17

Slide 17 text

TESTS ARE SLOW Parallelize: split long test in multiple small test Use the grid Luke!!!!!! Use the cloud Luke!!!!!! (https://saucelabs.com/)

Slide 18

Slide 18 text

FLAKY TEST Facebook runs each test X times to check if a test is flaky

Slide 19

Slide 19 text

IT'S JUST A DRIVER Missing out of the box functional testing solution Need to put several pieces together: testing framework (junit), report framework (NGReport)

Slide 20

Slide 20 text

BOILERPLATE CODE Automatic Functional Tests != Automatic Generation of Functional Tests Developers need to write boilerplate code, lot's of boilerplate code!!!!!!! Use PageObjects

Slide 21

Slide 21 text

SUGGESTION FOR A SAFE START Start small, stay small: write tests for the most often used case, or small case, then gradually add other tests Use Page Objects Automatic Page Object Generation, after each build

Slide 22

Slide 22 text

IS IT REALLY WORTH?? THERE IS NO SILVER BULLET!!!!!!

Slide 23

Slide 23 text

Q&A THANKS