SlideShare a Scribd company logo
“An Introduction to AngularJS End to End
Testing using Protractor”
Cubet Seminar
Presented by “Jenson”
“We help build and architect IT solutions”
About Cubet
Founded in 2007, Cubet Techno Labs
is an end-to-end SMAC (social,
mobile, analytics and cloud) consulting
company with offices at Kochi, India
and London, UK. With expertise in
insightful product strategy, well-crafted
design and proficient development for
high-end web and mobile application
technologies.
Where we stand
Visit – www.cubettech.com
What is Protractor ?
Visit – www.cubettech.com
 An AngularJS E2E Testing Framework
 Find Issues -Integration between components
 Introduced during AngularJS 1.2 and Beyond presentation
 A new replacement of the existing E2E Testing framework
 Nodejs program – end to end test run written in javascript
 Webdriver – control browsers and simulate user actions
 Jasmin – test syntax
 Allows running tests targeting remote addresses, No longer
need to have test files on the server being tested
What’s Different ?
Visit – www.cubettech.com
 Built on WebdriverJS and Selenium Server
 New syntax when writing tests
 Allows running tests targeting remote addresses, No longer
need to have test files on the server being tested
 Can take advantage of Selenium Grid to run multiple
browsers at once; ie Sauce Labs
 Has it’s own runner, no need for Karma
 Can use Jasmine or Mocha to write test suites
List of Contents:
Visit – www.cubettech.com
● HOW IT WORKS
● FRAMEWORK OR DRIVERS USED
● HOW TO INSTALL AND RUN
● WRITE A TEST
HOW IT WORKS
Visit – www.cubettech.com
1) Selenium server
Browser automation framework
 Selenium server
 Webdriver APIs
 Browser driver
2) Protractor
Node js program that support jasmine framework
HOW IT WORKS
Visit – www.cubettech.com
• Conjunction of protractor with selenium provide an automated testing infrastructure
• Can simulate user's interaction on angular application running in a browser or
mobile
JASMIN FRAMEWORK
Visit – www.cubettech.com
● It’s a test syntax
● One or more it blocks describe the requirement of your
application
● Commands + expectation = it blocks
● Commands = do something with application
Navigate to a page
Click on a button
Expectation = assert something about the application's state
Value of the field
Current url
Expectation with an it block fails – runner mark it as “failed”
After each and before each
Visit – www.cubettech.com
INSTALLATION
Visit – www.cubettech.com
●Installed via Node Package Manager
npm install protractor
●Install Selenium Standalone Server
node_modules/protractor/bin/install_selenium_standal
one
Note: Require JDK(java development kit)
The webdriver-manager -helper tool to easily get an instance of a Selenium Server running
• webdriver-manager update
• webdriver-manager start
http://localhost:4444/wd/hub
WRITE A TEST
Visit – www.cubettech.com
● Clean folder with
•spec file
•configuration file.
spec.js
describe('Protractor Demo App', function() {
it('should have a title', function() {
browser.get('http://juliemr.github.io/protractor-demo/');
expect(browser.getTitle()).toEqual('Super Calculator');
});
});
The describe and it syntax is from the Jasmine framework
browser - global created by Protractor
The Configuration File
Visit – www.cubettech.com
exports.config = {
framework: 'jasmine',
seleniumAddress: 'http://localhost:4444/wd/hub',
specs: ['spec.js'] ,
capabilities: {
browserName: 'firefox'
}
}
Chrome : default browser
RUN COMMAND : protractor config.js
RESULT : 1 tests, 1 assertion, 0 failures
INTERACTING WITH ELEMENTS
Visit – www.cubettech.com
// spec.js
describe('Protractor Demo App', function() {
it('should add one and two', function() {
browser.get('http://juliemr.github.io/protractor-demo/');
element(by.model('first')).sendKeys(1);
element(by.model('second')).sendKeys(2);
element(by.id('gobutton')).click();
expect(element(by.binding('latest')).getText()).
toEqual('5');
// This is wrong!
});
});
<input type=text ng-model="first">.
Finding Elements in a Test
Visit – www.cubettech.com
Use Selenium WebdriverJS Syntax:
ptor.findElement(protractor.By.x(‘...’));
or
ptor.findElements(protractor.By.x(‘...’));
findElement returns a single element, findElements returns an
array of elements.
Both will throw an exception if the locator cannot find the element
on the page
Protractor Locators
Visit – www.cubettech.com
protractor.By.className('redBtn')
protractor.By.css('.redBtn')
protractor.By.id('loginButton')
protractor.By.linkText('Go Home')
protractor.By.partialLinktext('Home')
protractor.By.name('email')
protractor.By.tagName('h2')
protractor.By.xpath('')
Protractor Locators (cont)
Visit – www.cubettech.com
protractor.By.binding('{{status}}')
protractor.By.select("user")
protractor.By.selectedOption("red")
protractor.By.input("user")
protractor.By.repeater("cat in pets")
protractor.By.repeater("cat in pets").row(1).column("{{cat.name}}"))
WebElement Methods
Visit – www.cubettech.com
clear() If this element is a text entry element, this will clear the value.
click() Click this element.
getAttribute(name) Get the value of a the given attribute of the element.
getCssValue(propertyName) Get the value of a given CSS property.
getLocation() Where on the page is the top left-hand corner of the rendered element?
getSize() What is the width and height of the rendered element?
getTagName() Get the tag name of this element.
WebElement Methods (cont)
Visit – www.cubettech.com
getText() Get the visible (i.e. not hidden by CSS) innerText of this element, including
sub-elements, without any leading or trailing whitespace.
isDisplayed() Is this element displayed or not? This method avoids the problem of having
to parse an element's "style" attribute.
isEnabled() Is the element currently enabled or not? This will generally return true for
everything but disabled input elements.
isSelected() Determine whether or not this element is selected or not.
sendKeys(keysToSend) Use this method to simulate typing into an element, which may set its value.
Resources
Visit – www.cubettech.com
Protractor Github Page - https://github.com/angular/protractor
WebdriverJS User Guide - https://code.google.com/p/selenium/wiki/WebDriverJs
Stackoverflow WebdriverJS Content - http://stackoverflow.com/search?q=%5Bselenium%5D+webdriverjs
Our Technologies Stack:
Server Side Application JavaScript Frameworks
Mobile App Development
Database System and Cloud
Visit – www.cubettech.com
THANKS!
ANY QUESTIONS? PLEASE GET IN TOUCH!
www.cubettech.com
Email : info@cubettech.com
Skype : cubet.se
Phone: +91 484 405 4324
Contact us:
Kemp House
160 City Road
London- EC1V2NX,
UK.info@cubettech.com
+44 2071938618
Carnival Info Park,
Unit IX-C, 9th floor
PhaseIV,
Kochi, Kerala, India
info@cubettech.com
+91 484 4054324

More Related Content

PDF
Carmen Popoviciu - Protractor styleguide | Codemotion Milan 2015
PPTX
Angular UI Testing with Protractor
PPTX
Protractor Tutorial Quality in Agile 2015
PDF
AngularJS and Protractor
PPTX
Protractor training
PPTX
Better End-to-End Testing with Page Objects Model using Protractor
PPTX
Protractor overview
PPTX
Protractor for angularJS
Carmen Popoviciu - Protractor styleguide | Codemotion Milan 2015
Angular UI Testing with Protractor
Protractor Tutorial Quality in Agile 2015
AngularJS and Protractor
Protractor training
Better End-to-End Testing with Page Objects Model using Protractor
Protractor overview
Protractor for angularJS

What's hot (20)

PPTX
Protractor survival guide
PDF
Introduction to Protractor
PPTX
Automated Smoke Tests with Protractor
DOCX
Protractor end-to-end testing framework for angular js
PPTX
Automated Testing using JavaScript
PDF
Automated Web Testing using JavaScript
PDF
Protractor: Tips & Tricks
PPTX
Using protractor to build automated ui tests
PDF
Automated Testing in Angular Slides
PDF
Workshop - E2e tests with protractor
PDF
Join the darkside: Selenium testing with Nightwatch.js
PPT
Intro to Service Worker API and its use cases
PDF
Testing Code.org's Interactive CS Curriculum
PPTX
Automation using Javascript
PDF
Better Page Object Handling with Loadable Component Pattern
PDF
Testing nightwatch, by David Torroija
PDF
Front-End Testing: Demystified
PDF
Automation Abstraction Layers: Page Objects and Beyond
PPTX
Marcin Wasilczyk - Page objects with selenium
PDF
APIs: A Better Alternative to Page Objects
Protractor survival guide
Introduction to Protractor
Automated Smoke Tests with Protractor
Protractor end-to-end testing framework for angular js
Automated Testing using JavaScript
Automated Web Testing using JavaScript
Protractor: Tips & Tricks
Using protractor to build automated ui tests
Automated Testing in Angular Slides
Workshop - E2e tests with protractor
Join the darkside: Selenium testing with Nightwatch.js
Intro to Service Worker API and its use cases
Testing Code.org's Interactive CS Curriculum
Automation using Javascript
Better Page Object Handling with Loadable Component Pattern
Testing nightwatch, by David Torroija
Front-End Testing: Demystified
Automation Abstraction Layers: Page Objects and Beyond
Marcin Wasilczyk - Page objects with selenium
APIs: A Better Alternative to Page Objects
Ad

Similar to An Introduction to AngularJS End to End Testing using Protractor (20)

PPTX
Protractor End To End Testing For AngularJS
PPTX
Introduction to Protractor - Habilelabs
PDF
TestingAR XX - Protractor e2e Test Framework - Introduction what we have lear...
PPTX
ProtractorJS for automated testing of Angular 1.x/2.x applications
PPTX
Олександр Хотемський “ProtractorJS як інструмент браузерної автоматизації для...
PPTX
Knowledge of web ui for automation testing
PPTX
Protractor framework architecture with example
PPTX
QA Fes 2016. Александр Хотемской. Обзор ProtractorJS как фреймворка для брауз...
PDF
Sharing the pain using Protractor
PPTX
Presentation_Protractor
PPTX
Protractor Testing Automation Tool Framework / Jasmine Reporters
PPTX
Selenium with protractor
PDF
Sharing (less) Pain of using Protractor & WebDriver
PDF
Moving from selenium to protractor for test automation
PPTX
Protractor
PDF
How to Use Playwright Locators_ A Detailed Guide.pdf
PPTX
[DN Scrum Breakfast] Protractor: E2E Testing for AngularJS (by Thuy Nguyen)
PPTX
Selenium web driver
PPTX
Protractor: The Hacker way (NG-MY 2019)
PPTX
Selenium.pptx
Protractor End To End Testing For AngularJS
Introduction to Protractor - Habilelabs
TestingAR XX - Protractor e2e Test Framework - Introduction what we have lear...
ProtractorJS for automated testing of Angular 1.x/2.x applications
Олександр Хотемський “ProtractorJS як інструмент браузерної автоматизації для...
Knowledge of web ui for automation testing
Protractor framework architecture with example
QA Fes 2016. Александр Хотемской. Обзор ProtractorJS как фреймворка для брауз...
Sharing the pain using Protractor
Presentation_Protractor
Protractor Testing Automation Tool Framework / Jasmine Reporters
Selenium with protractor
Sharing (less) Pain of using Protractor & WebDriver
Moving from selenium to protractor for test automation
Protractor
How to Use Playwright Locators_ A Detailed Guide.pdf
[DN Scrum Breakfast] Protractor: E2E Testing for AngularJS (by Thuy Nguyen)
Selenium web driver
Protractor: The Hacker way (NG-MY 2019)
Selenium.pptx
Ad

More from Cubet Techno Labs (6)

PPTX
Sass_Cubet seminar
PPTX
Drupal_cubet seminar
PPTX
Let's start with REDUX
PPTX
JMeter_ Cubet Seminar ppt
PPTX
Fabricjs ppt
PPTX
Angularjs 2
Sass_Cubet seminar
Drupal_cubet seminar
Let's start with REDUX
JMeter_ Cubet Seminar ppt
Fabricjs ppt
Angularjs 2

Recently uploaded (20)

PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
Empathic Computing: Creating Shared Understanding
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PPTX
MYSQL Presentation for SQL database connectivity
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
Electronic commerce courselecture one. Pdf
PDF
KodekX | Application Modernization Development
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
cuic standard and advanced reporting.pdf
PDF
Modernizing your data center with Dell and AMD
PPTX
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PPTX
A Presentation on Artificial Intelligence
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Empathic Computing: Creating Shared Understanding
NewMind AI Weekly Chronicles - August'25 Week I
MYSQL Presentation for SQL database connectivity
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
Building Integrated photovoltaic BIPV_UPV.pdf
Electronic commerce courselecture one. Pdf
KodekX | Application Modernization Development
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Chapter 3 Spatial Domain Image Processing.pdf
“AI and Expert System Decision Support & Business Intelligence Systems”
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Diabetes mellitus diagnosis method based random forest with bat algorithm
cuic standard and advanced reporting.pdf
Modernizing your data center with Dell and AMD
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
The Rise and Fall of 3GPP – Time for a Sabbatical?
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
A Presentation on Artificial Intelligence

An Introduction to AngularJS End to End Testing using Protractor

  • 1. “An Introduction to AngularJS End to End Testing using Protractor” Cubet Seminar Presented by “Jenson” “We help build and architect IT solutions”
  • 2. About Cubet Founded in 2007, Cubet Techno Labs is an end-to-end SMAC (social, mobile, analytics and cloud) consulting company with offices at Kochi, India and London, UK. With expertise in insightful product strategy, well-crafted design and proficient development for high-end web and mobile application technologies. Where we stand Visit – www.cubettech.com
  • 3. What is Protractor ? Visit – www.cubettech.com  An AngularJS E2E Testing Framework  Find Issues -Integration between components  Introduced during AngularJS 1.2 and Beyond presentation  A new replacement of the existing E2E Testing framework  Nodejs program – end to end test run written in javascript  Webdriver – control browsers and simulate user actions  Jasmin – test syntax  Allows running tests targeting remote addresses, No longer need to have test files on the server being tested
  • 4. What’s Different ? Visit – www.cubettech.com  Built on WebdriverJS and Selenium Server  New syntax when writing tests  Allows running tests targeting remote addresses, No longer need to have test files on the server being tested  Can take advantage of Selenium Grid to run multiple browsers at once; ie Sauce Labs  Has it’s own runner, no need for Karma  Can use Jasmine or Mocha to write test suites
  • 5. List of Contents: Visit – www.cubettech.com ● HOW IT WORKS ● FRAMEWORK OR DRIVERS USED ● HOW TO INSTALL AND RUN ● WRITE A TEST
  • 6. HOW IT WORKS Visit – www.cubettech.com 1) Selenium server Browser automation framework  Selenium server  Webdriver APIs  Browser driver 2) Protractor Node js program that support jasmine framework
  • 7. HOW IT WORKS Visit – www.cubettech.com • Conjunction of protractor with selenium provide an automated testing infrastructure • Can simulate user's interaction on angular application running in a browser or mobile
  • 8. JASMIN FRAMEWORK Visit – www.cubettech.com ● It’s a test syntax ● One or more it blocks describe the requirement of your application ● Commands + expectation = it blocks ● Commands = do something with application Navigate to a page Click on a button Expectation = assert something about the application's state Value of the field Current url Expectation with an it block fails – runner mark it as “failed” After each and before each
  • 10. INSTALLATION Visit – www.cubettech.com ●Installed via Node Package Manager npm install protractor ●Install Selenium Standalone Server node_modules/protractor/bin/install_selenium_standal one Note: Require JDK(java development kit) The webdriver-manager -helper tool to easily get an instance of a Selenium Server running • webdriver-manager update • webdriver-manager start http://localhost:4444/wd/hub
  • 11. WRITE A TEST Visit – www.cubettech.com ● Clean folder with •spec file •configuration file. spec.js describe('Protractor Demo App', function() { it('should have a title', function() { browser.get('http://juliemr.github.io/protractor-demo/'); expect(browser.getTitle()).toEqual('Super Calculator'); }); }); The describe and it syntax is from the Jasmine framework browser - global created by Protractor
  • 12. The Configuration File Visit – www.cubettech.com exports.config = { framework: 'jasmine', seleniumAddress: 'http://localhost:4444/wd/hub', specs: ['spec.js'] , capabilities: { browserName: 'firefox' } } Chrome : default browser RUN COMMAND : protractor config.js RESULT : 1 tests, 1 assertion, 0 failures
  • 13. INTERACTING WITH ELEMENTS Visit – www.cubettech.com // spec.js describe('Protractor Demo App', function() { it('should add one and two', function() { browser.get('http://juliemr.github.io/protractor-demo/'); element(by.model('first')).sendKeys(1); element(by.model('second')).sendKeys(2); element(by.id('gobutton')).click(); expect(element(by.binding('latest')).getText()). toEqual('5'); // This is wrong! }); }); <input type=text ng-model="first">.
  • 14. Finding Elements in a Test Visit – www.cubettech.com Use Selenium WebdriverJS Syntax: ptor.findElement(protractor.By.x(‘...’)); or ptor.findElements(protractor.By.x(‘...’)); findElement returns a single element, findElements returns an array of elements. Both will throw an exception if the locator cannot find the element on the page
  • 15. Protractor Locators Visit – www.cubettech.com protractor.By.className('redBtn') protractor.By.css('.redBtn') protractor.By.id('loginButton') protractor.By.linkText('Go Home') protractor.By.partialLinktext('Home') protractor.By.name('email') protractor.By.tagName('h2') protractor.By.xpath('')
  • 16. Protractor Locators (cont) Visit – www.cubettech.com protractor.By.binding('{{status}}') protractor.By.select("user") protractor.By.selectedOption("red") protractor.By.input("user") protractor.By.repeater("cat in pets") protractor.By.repeater("cat in pets").row(1).column("{{cat.name}}"))
  • 17. WebElement Methods Visit – www.cubettech.com clear() If this element is a text entry element, this will clear the value. click() Click this element. getAttribute(name) Get the value of a the given attribute of the element. getCssValue(propertyName) Get the value of a given CSS property. getLocation() Where on the page is the top left-hand corner of the rendered element? getSize() What is the width and height of the rendered element? getTagName() Get the tag name of this element.
  • 18. WebElement Methods (cont) Visit – www.cubettech.com getText() Get the visible (i.e. not hidden by CSS) innerText of this element, including sub-elements, without any leading or trailing whitespace. isDisplayed() Is this element displayed or not? This method avoids the problem of having to parse an element's "style" attribute. isEnabled() Is the element currently enabled or not? This will generally return true for everything but disabled input elements. isSelected() Determine whether or not this element is selected or not. sendKeys(keysToSend) Use this method to simulate typing into an element, which may set its value.
  • 19. Resources Visit – www.cubettech.com Protractor Github Page - https://github.com/angular/protractor WebdriverJS User Guide - https://code.google.com/p/selenium/wiki/WebDriverJs Stackoverflow WebdriverJS Content - http://stackoverflow.com/search?q=%5Bselenium%5D+webdriverjs
  • 20. Our Technologies Stack: Server Side Application JavaScript Frameworks Mobile App Development Database System and Cloud Visit – www.cubettech.com
  • 21. THANKS! ANY QUESTIONS? PLEASE GET IN TOUCH! www.cubettech.com Email : info@cubettech.com Skype : cubet.se Phone: +91 484 405 4324
  • 22. Contact us: Kemp House 160 City Road London- EC1V2NX, UK.info@cubettech.com +44 2071938618 Carnival Info Park, Unit IX-C, 9th floor PhaseIV, Kochi, Kerala, India info@cubettech.com +91 484 4054324