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)

PDF
Selenium RC: Automated Testing of Modern Web Applications
PDF
ForwardJS 2017 - Fullstack end-to-end Test Automation with node.js
PPTX
AngularJS training - Day 1 - Basics: Why, What and basic features of AngularJS
PPTX
Mastering Test Automation: How To Use Selenium Successfully
PDF
Web UI test automation instruments
PPTX
Improving Your Selenium WebDriver Tests - Belgium testing days_2016
PDF
gDayX 2013 - Advanced AngularJS - Nicolas Embleton
PDF
Node.js and Selenium Webdriver, a journey from the Java side
PPTX
An Introduction to Web Components
PDF
Effective testing of rich internet applications
PPT
Behavior Driven Development by Example
PPTX
Angular - Beginner
PPTX
Introduction to Protractor - Habilelabs
PDF
Droidcon Paris 2015
PPTX
Good karma: UX Patterns and Unit Testing in Angular with Karma
PDF
React && React Native workshop
PDF
Automated acceptance test
PPTX
Introduction to Angular js 2.0
PDF
Choose Your Own Adventure with JHipster & Kubernetes - Denver JUG 2020
PDF
Moving from selenium to protractor for test automation
Selenium RC: Automated Testing of Modern Web Applications
ForwardJS 2017 - Fullstack end-to-end Test Automation with node.js
AngularJS training - Day 1 - Basics: Why, What and basic features of AngularJS
Mastering Test Automation: How To Use Selenium Successfully
Web UI test automation instruments
Improving Your Selenium WebDriver Tests - Belgium testing days_2016
gDayX 2013 - Advanced AngularJS - Nicolas Embleton
Node.js and Selenium Webdriver, a journey from the Java side
An Introduction to Web Components
Effective testing of rich internet applications
Behavior Driven Development by Example
Angular - Beginner
Introduction to Protractor - Habilelabs
Droidcon Paris 2015
Good karma: UX Patterns and Unit Testing in Angular with Karma
React && React Native workshop
Automated acceptance test
Introduction to Angular js 2.0
Choose Your Own Adventure with JHipster & Kubernetes - Denver JUG 2020
Moving from selenium to protractor for test automation
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
Spectral efficient network and resource selection model in 5G networks
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
How Onsite IT Support Drives Business Efficiency, Security, and Growth.pdf
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
AI And Its Effect On The Evolving IT Sector In Australia - Elevate
PDF
Transforming Manufacturing operations through Intelligent Integrations
PDF
solutions_manual_-_materials___processing_in_manufacturing__demargo_.pdf
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Electronic commerce courselecture one. Pdf
PPTX
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
CIFDAQ's Market Insight: SEC Turns Pro Crypto
PPTX
Comunidade Salesforce São Paulo - Desmistificando o Omnistudio (Vlocity)
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
Spectral efficient network and resource selection model in 5G networks
Advanced methodologies resolving dimensionality complications for autism neur...
How Onsite IT Support Drives Business Efficiency, Security, and Growth.pdf
20250228 LYD VKU AI Blended-Learning.pptx
Understanding_Digital_Forensics_Presentation.pptx
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
The Rise and Fall of 3GPP – Time for a Sabbatical?
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
“AI and Expert System Decision Support & Business Intelligence Systems”
AI And Its Effect On The Evolving IT Sector In Australia - Elevate
Transforming Manufacturing operations through Intelligent Integrations
solutions_manual_-_materials___processing_in_manufacturing__demargo_.pdf
Chapter 3 Spatial Domain Image Processing.pdf
Per capita expenditure prediction using model stacking based on satellite ima...
Electronic commerce courselecture one. Pdf
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
CIFDAQ's Market Insight: SEC Turns Pro Crypto
Comunidade Salesforce São Paulo - Desmistificando o Omnistudio (Vlocity)
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...

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 : [email protected] Skype : cubet.se Phone: +91 484 405 4324
  • 22. Contact us: Kemp House 160 City Road London- EC1V2NX, [email protected] +44 2071938618 Carnival Info Park, Unit IX-C, 9th floor PhaseIV, Kochi, Kerala, India [email protected] +91 484 4054324