Date post: | 13-Aug-2015 |
Category: |
Technology |
Upload: | - |
View: | 213 times |
Download: | 0 times |
AUTOMATED UI TESTING
Presented by Chung Chieh-Lun
Integration Test
“Without automated end to end tests delivering a new release of an
application becomes burdensome !”
Integration Test
Integration Test
Only UI exposed
The investment pays off quickly
Automated tests
Selenium
“Selenium automates browser”
Selenium
Free
Whatever users do in the browser
Get everything at: http://www.seleniumhq.org/
Can Selenium automate app?
Selenium Language Bindings Core
Third Party
Java C# Ruby Python Javascript
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
Selenium Components
Selenium IDE
Selenium RC (Remote Control)
Selenium Grid
Selenium 2.0 (Webdriver)
Selenium IDE
Firefox add-on Exports as a reusable script to play back
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
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
Webdriver[Selenium 2.0]
Controls the browser from the OS level
Redundancy Confusion
Webdriver Selenium RC
Speed
API
BroserSupport
Need a real, visible browserHtmlUnit browser
Simple
Headless HtmlUnit Browser
GUI-Less browser for Java programs
A way to simulate a browser for testing
http://htmlunit.sourceforge.net/gettingStarted.html
If you want to...
Run your tests on different browser and operating system
Third-Party
OR?
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
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());
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); });
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
ControlFlow
NodeJS NPM
Selenium RC npm install soda https://github.com/learnboost/soda
NodeJS NPM
WebDriverJS for Node npm install selenium-webdriver npm install webdriverio npm install protractor
More...
https://github.com/beatfactor/nightwatchnpm
Protractor
API: https://angular.github.io/protractor/#/api
$ webdriver-manager update
$ webdriver-manager start
$ protractor spec.js
Demo
Test Items Redirect /login
Show the signin panel
Autheticate a user
Workflow Integration
Can we just run
a single command
and
everything go smooth ?
Gulp
“Automate and enhance your workflow”
Gulp
Javascript Test Framework
Install and start a standalone selenium server
Synchronised browser testing
Gulp – BrowserSync
npm install browserSync
http://www.browsersync.io/
npm install selenium-standalone
Install and start selenium server
Gulp
Gulp Test
Demo
Test Items Link button
Set cookie value
Take a screenshot