selenium

36
AUTOMATED UI TESTING Presented by Chung Chieh-Lun

Upload: -

Post on 13-Aug-2015

213 views

Category:

Technology


0 download

TRANSCRIPT

Page 1: Selenium

AUTOMATED UI TESTING

Presented by Chung Chieh-Lun

Page 2: Selenium

Integration Test

“Without automated end to end tests delivering a new release of an

application becomes burdensome !”

Page 3: Selenium

Integration Test

Page 4: Selenium

Integration Test

Only UI exposed

The investment pays off quickly

Automated tests

Page 5: Selenium

Selenium

“Selenium automates browser”

Page 6: Selenium

Selenium

Free

Whatever users do in the browser

Get everything at: http://www.seleniumhq.org/

Page 7: Selenium

Can Selenium automate app?

Page 8: Selenium

Selenium Language Bindings Core

Third Party

Java C# Ruby Python Javascript

Page 9: Selenium

How to use Java JRE/JDK Install latest Selenium Serverhttps://selenium-release.storage.googleapis.com/index.html

Install Java Selenium Client Driverex. ChromeDriverhttp://chromedriver.storage.googleapis.com/index.html

Page 10: Selenium

Selenium Components

Selenium IDE

Selenium RC (Remote Control)

Selenium Grid

Selenium 2.0 (Webdriver)

Page 11: Selenium

Selenium IDE

Firefox add-on Exports as a reusable script to play back

Page 12: Selenium
Page 13: Selenium

Selenium RC

Launch  RC Server

  Write Your Commands

Send to RC Server

Interact with the browser

Respond to RC Server

Fetch new instructions

Repeat

middleman

Your Selenium Commands

Page 14: Selenium

Selenium RC

Step 1 -> RC Server relay instructions from your test program

Step 2 -> Selenium Core will execute the instructions as javascript commands

Step 3 -> The browser will obey the instructions of Selenium Core and relay its response to the RC Server

Step 4 -> The RC Server will receive the response of the browser and then display the results to you

Step 5 -> RC Server will fetch the next instruction from your test script to repeat the whole cycle

Page 15: Selenium

Webdriver[Selenium 2.0]

Controls the browser from the OS level

Page 16: Selenium

Redundancy Confusion

Webdriver Selenium RC

Speed

API

BroserSupport

 

Need a real, visible browserHtmlUnit browser

Simple

Page 17: Selenium

Headless HtmlUnit Browser

GUI-Less browser for Java programs

A way to simulate a browser for testing

http://htmlunit.sourceforge.net/gettingStarted.html

Page 18: Selenium

If you want to...

Run your tests on different browser and operating system

Third-Party

OR?

Page 19: Selenium

Selenium Grid

Distribute test execution across several machines

Save time in execution of your test suites

http://www.guru99.com/introduction-to-selenium-grid.html

Page 20: Selenium

 WebDriverJS

Asynchronous

Example : Google search [Java]

driver.get("http://www.google.com");driver.findElement(By.name("q")).sendKeys("webdriver");driver.findElement(By.name("btnG")).click();assertEquals("webdriver - Google Search", driver.getTitle());

Page 21: Selenium

WebDriverJS

Promise An object that can execute whatever you give it after it has finished

driver.get("http://www.google.com") .then(function() {     return driver.findElement(By.name("q")); }) .then(function(q) {     return q.sendKeys("webdriver"); }) .then(function() {     return driver.findElement(By.name("btnG")); }) .then(function(btnG) {     return btnG.click(); }) .then(function() {     return driver.getTitle(); }) .then(function(title) {     assertEquals("webdriver - Google Search", title); });

Page 22: Selenium

ControlFlow 

A wrapper for Promise

It maintains a list of schedule actions

The exposed functions in WebDriverJS do not actually do their stuff

It puts every new entry in the then callback of the last entry of the list

Page 23: Selenium

ControlFlow 

Page 24: Selenium

NodeJS NPM

Selenium RC npm install soda https://github.com/learnboost/soda

Page 25: Selenium

NodeJS NPM

 WebDriverJS for Node npm install selenium-webdriver npm install webdriverio npm install protractor

Page 26: Selenium

More...

https://github.com/beatfactor/nightwatchnpm

Page 27: Selenium

Protractor

API: https://angular.github.io/protractor/#/api

$ webdriver-manager update

$ webdriver-manager start

$ protractor spec.js

Page 28: Selenium

Demo

Test Items Redirect /login

Show the signin panel

Autheticate a user

Page 29: Selenium

Workflow Integration

Can we just run

a single command

and

everything go smooth ?

Page 30: Selenium

Gulp

“Automate and enhance your workflow”

Page 31: Selenium

Gulp

Javascript Test Framework

Install and start a standalone selenium server

Synchronised browser testing

Page 32: Selenium

Gulp – BrowserSync

npm install browserSync

http://www.browsersync.io/

Page 33: Selenium

npm install selenium-standalone

Install and start selenium server

Page 34: Selenium

Gulp

Page 35: Selenium

Gulp Test

Page 36: Selenium

Demo

Test Items Link button

Set cookie value

Take a screenshot