Better End-to-End Testing With
Page Object Model
Using Protractor
Kasun Kodagoda | Team Finale
Trainee Software Engineer | 99X Technology
Overview
‱ Protractor
‱ What is it?
‱ Getting Up and Running
‱ Basic Requirements
‱ Page Objects
‱ What is it?
‱ Why Use it?
‱ A Deeper Dive..
‱ Demo
Protractor
What Is It?
“Protractor is an end-to-end test framework for AngularJS
applications. Protractor runs tests against your application running in
a real browser, interacting with it as a user would”
Source: Official Protractor Website
What Is It?
‱ Combination of powerful technologies and tools for testing
Node.js, Selenium, Jasmine, WebDriver, Cucumber, Mocha
‱ Wrapper for Selenium, made for Angular.js
‱ Uses angular specific constructs for capturing elements
Model, bindings, repeaters etc.
‱ Runs on real browsers as well as headless browsers
Get Up And Running..
‱ Install Node.js
‱ Install Protractor
npm install –g protractor
‱ Install WebDriver
webdriver-manager update
‱ Start WebDriver
webdriver-manager start // do this before you run the tests
Basic Requirements
‱ You’ll need 2 basic files to start,
‱ A Test/Spec file
Contains the element references, assertions
‱ The Configuration File
Contains the configuration options for running protractor
‱ Use your preferred test framework to write tests
‱ Jasmine – Fully Supported
‱ Mocha – Limited Support
‱ Cucumber – Limited Support
Sample Config File
exports.config = {
seleniumAddress: 'http://localhost:4444/wd/hub',
capabilities: {
'browserName': 'chrome'
},
specs: [
'specs/*Spec.js'
],
jasmineNodeOpts: {
showColors: true
}
};
Sample Test
describe('Test Home Page', function () {
it("Should display the text typed in to the input field.", function () {
browser.get('http://localhost:8080/#/');
// Type in a value to input field
var textInput = element(by.model('sampleInput'));
textInput.sendKeys('The KVK Blog');
// Check if the same value is displayed
var displayField = element(by.binding('sampleInput'));
expect(displayField.getText()).toEqual('The KVK Blog');
});
});
Conventional UI Tests
‱ Element references are inside tests
‱ Test are cluttered
‱ Less readable
‱ Very fragile
Page Objects Pattern
What Is A Page Object?
“A page object is an object-oriented class that serves as an interface to
a page of your AUT”
‱ Wraps a HTML page/fragment
‱ Provide Application Specific API
‱ Hides the underlying complexity
‱ Used to manipulate elements on page
Why Use Page Objects?
‱ Reduce Code Duplication
‱ Reusable Page Objects
‱ More Readable Tests
‱ Less Vulnerable to Break
‱ More Maintainable Tests
Especially in Agile Based Projects
A Deeper Dive

Return Types
‱ Methods in Page Objects should return fundamental types
Strings, Dates, Booleans
‱ It can return other complex types as well
Promises, other Page Objects
A Deeper Dive

‱ Method names can be much closer to what the user is actually doing.
var inputField = element(by.model(‘first_name’);
inputField.sendKeys(‘Kasun’);
Or
element(by.model(‘first_name’)).sendKeys(‘Kasun’);
Instead We can use
somePage.addFirstName(‘Kasun’);
A Deeper Dive

The Dilemma
‱ Use of assertions
‱ Include Assertions inside Page Objects
‱ Not Include Assertions inside Page Objects
‱ It’s Subjective and the Choice is yours

A Deeper Dive

No Assertions in Page Objects for Us. Why??
‱ Separation of Responsibility
‱ Page Objects should only provide access to HTML pages
‱ Page Objects become longer
A Deeper Dive

What We Believe
“If what we test changes, The assertions and the tests should change”
“If the HTML page changes, The Page Object should change”
This,
‱ Allows us to easily modify the tests/specs when functionality or
underlying HTML pages change overtime
http://goo.gl/MFNy9C
https://github.com/kasunkv/e2e-sample-app.git
Demo
You Have NO Questions

Right?... ;)
Thank You
For Not Throwing Rocks At Me ^_^

More Related Content

PPTX
Protractor training
PDF
AngularJS and Protractor
PPTX
Protractor for angularJS
DOCX
Protractor end-to-end testing framework for angular js
PPTX
Protractor overview
PPTX
Automated Testing with Cucumber, PhantomJS and Selenium
PDF
Carmen Popoviciu - Protractor styleguide | Codemotion Milan 2015
PPTX
Protractor survival guide
Protractor training
AngularJS and Protractor
Protractor for angularJS
Protractor end-to-end testing framework for angular js
Protractor overview
Automated Testing with Cucumber, PhantomJS and Selenium
Carmen Popoviciu - Protractor styleguide | Codemotion Milan 2015
Protractor survival guide

What's hot (20)

PPTX
An Introduction to AngularJS End to End Testing using Protractor
PDF
Automated Web Testing using JavaScript
PPTX
Automated Testing using JavaScript
PPTX
Protractor Tutorial Quality in Agile 2015
PPTX
Angular UI Testing with Protractor
PDF
Introduction to Protractor
KEY
Jellyfish, JSCONF 2011
PDF
APIs: A Better Alternative to Page Objects
PPTX
Automation using Javascript
PDF
Better Page Object Handling with Loadable Component Pattern
PDF
Front-End Testing: Demystified
PDF
Automated Testing in Angular Slides
PDF
Testing Code.org's Interactive CS Curriculum
PDF
Join the darkside: Selenium testing with Nightwatch.js
PDF
Testing nightwatch, by David Torroija
PDF
How to Use Selenium, Successfully
PPTX
Selenium for Jobseekers
PPTX
Automated Smoke Tests with Protractor
PPT
Intro to Service Worker API and its use cases
PPTX
Selenium with protractor
An Introduction to AngularJS End to End Testing using Protractor
Automated Web Testing using JavaScript
Automated Testing using JavaScript
Protractor Tutorial Quality in Agile 2015
Angular UI Testing with Protractor
Introduction to Protractor
Jellyfish, JSCONF 2011
APIs: A Better Alternative to Page Objects
Automation using Javascript
Better Page Object Handling with Loadable Component Pattern
Front-End Testing: Demystified
Automated Testing in Angular Slides
Testing Code.org's Interactive CS Curriculum
Join the darkside: Selenium testing with Nightwatch.js
Testing nightwatch, by David Torroija
How to Use Selenium, Successfully
Selenium for Jobseekers
Automated Smoke Tests with Protractor
Intro to Service Worker API and its use cases
Selenium with protractor
Ad

Viewers also liked (19)

PDF
Protractor: Tips & Tricks
PDF
Sharing the pain using Protractor
PDF
Test Data - Food for your Test Automation Framework
PDF
Introduction to Protractor
PDF
Intro to Unit Testing in AngularJS
PDF
Testing Backbone applications with Jasmine
PPTX
Jasmine framework
PPTX
ĐžĐœŃ‚Đ”Ń€ĐœĐ”Ń‚ ĐČ ŃĐŸŃ†ĐžĐŸĐ»ĐŸĐłĐžĐž ĐČĐ°Đ¶ĐœĐ”ĐčшОД ĐžĐœŃ„ĐŸŃ€ĐŒĐ°Ń†ĐžĐŸĐœĐœŃ‹Đ” саĐčты ЎаЎаЎаЎаЎ)))
 
PPTX
Automated Acceptance Testing Example
PPTX
The sweet smell of jasmine for testing JavaScript
PDF
Advanced Jasmine
PDF
Testing Angular 2 Applications - HTML5 Denver 2016
PDF
20150128 angular js_headless_testing
PDF
Thinking outside the box (SOX)
PDF
10 Tips For Serverless Backends With NodeJS and AWS Lambda
PDF
Angular Testing
PPTX
Presentation_Protractor
PPTX
ProtractorJS for automated testing of Angular 1.x/2.x applications
PPT
Protractor powerpoint
Protractor: Tips & Tricks
Sharing the pain using Protractor
Test Data - Food for your Test Automation Framework
Introduction to Protractor
Intro to Unit Testing in AngularJS
Testing Backbone applications with Jasmine
Jasmine framework
ĐžĐœŃ‚Đ”Ń€ĐœĐ”Ń‚ ĐČ ŃĐŸŃ†ĐžĐŸĐ»ĐŸĐłĐžĐž ĐČĐ°Đ¶ĐœĐ”ĐčшОД ĐžĐœŃ„ĐŸŃ€ĐŒĐ°Ń†ĐžĐŸĐœĐœŃ‹Đ” саĐčты ЎаЎаЎаЎаЎ)))
 
Automated Acceptance Testing Example
The sweet smell of jasmine for testing JavaScript
Advanced Jasmine
Testing Angular 2 Applications - HTML5 Denver 2016
20150128 angular js_headless_testing
Thinking outside the box (SOX)
10 Tips For Serverless Backends With NodeJS and AWS Lambda
Angular Testing
Presentation_Protractor
ProtractorJS for automated testing of Angular 1.x/2.x applications
Protractor powerpoint
Ad

Similar to Better End-to-End Testing with Page Objects Model using Protractor (20)

PPTX
DSL, Page Object and WebDriver – the path to reliable functional tests.pptx
PPTX
DSL, Page Object Đž WebDriver – путь Đș ĐœĐ°ĐŽĐ”Đ¶ĐœŃ‹ĐŒ Ń„ŃƒĐœĐșŃ†ĐžĐŸĐœĐ°Đ»ŃŒĐœŃ‹ĐŒ Ń‚Đ”ŃŃ‚Đ°ĐŒ
 
PPTX
Improving Your Selenium WebDriver Tests - Belgium testing days_2016
PDF
Mastering react with redux
PPTX
Better Page Object Handling with Loadable Component Pattern
 
PPTX
AngularJS One Day Workshop
PDF
Escaping Test Hell - ACCU 2014
PDF
Quick start with AngularJS
PPTX
Become a Full Stack Web Developer (.NET) - Thisiswali
PDF
Better Page Object Handling with Loadable Component Pattern - SQA Days 20, Be...
PPTX
Galenframework
PPTX
Galenframework
PPTX
Galen Framework - Responsive Design Automation
PPTX
Selenium Online Training
PDF
Testing-Tools-Magnitia-Content.pdf
PDF
Selenium-with-Java-Course-Content-Magnitia.pdf
PDF
Selenium-with-Java-Course-Content-Magnitia.pdf
PDF
Selenium Online Training
PPTX
Angular patterns
PDF
Kevin Whinnery: Write Better JavaScript
DSL, Page Object and WebDriver – the path to reliable functional tests.pptx
DSL, Page Object Đž WebDriver – путь Đș ĐœĐ°ĐŽĐ”Đ¶ĐœŃ‹ĐŒ Ń„ŃƒĐœĐșŃ†ĐžĐŸĐœĐ°Đ»ŃŒĐœŃ‹ĐŒ Ń‚Đ”ŃŃ‚Đ°ĐŒ
 
Improving Your Selenium WebDriver Tests - Belgium testing days_2016
Mastering react with redux
Better Page Object Handling with Loadable Component Pattern
 
AngularJS One Day Workshop
Escaping Test Hell - ACCU 2014
Quick start with AngularJS
Become a Full Stack Web Developer (.NET) - Thisiswali
Better Page Object Handling with Loadable Component Pattern - SQA Days 20, Be...
Galenframework
Galenframework
Galen Framework - Responsive Design Automation
Selenium Online Training
Testing-Tools-Magnitia-Content.pdf
Selenium-with-Java-Course-Content-Magnitia.pdf
Selenium-with-Java-Course-Content-Magnitia.pdf
Selenium Online Training
Angular patterns
Kevin Whinnery: Write Better JavaScript

More from Kasun Kodagoda (15)

PPTX
Using GitHub Actions to Deploy your Workloads to Azure
PPTX
Feature Toggle for .Net Core Apps on Azure with Azure App Configuration Featu...
PPTX
Get On Top of Azure Resource Security Using Secure DevOps Kit for Azure
PPTX
Centralized Configuration Management for the Cloud with Azure App Configuration
PPTX
Serverless in the Azure World
PPTX
Role of Test Automation in Modern Software Delivery Pipelines
PPTX
Demystifying Azure Certifications
PPTX
Good Bye Credentials in Code, Welcome Azure Managed Identities
PPTX
DevOps: Why Should We Care?
PPTX
Introduction to Microsoft Azure
PPTX
Building Custom Visual Studio Team Service Build Tasks With VSTS DevOps Task SDK
PPTX
Building a Continuous Delivery Pipeline With Visual Studio
PPTX
Going Serverless with Azure Functions #1 - Introduction to Azure Functions
PPTX
Making Money with Technology
PPTX
Monetizing Windows Phone Apps
Using GitHub Actions to Deploy your Workloads to Azure
Feature Toggle for .Net Core Apps on Azure with Azure App Configuration Featu...
Get On Top of Azure Resource Security Using Secure DevOps Kit for Azure
Centralized Configuration Management for the Cloud with Azure App Configuration
Serverless in the Azure World
Role of Test Automation in Modern Software Delivery Pipelines
Demystifying Azure Certifications
Good Bye Credentials in Code, Welcome Azure Managed Identities
DevOps: Why Should We Care?
Introduction to Microsoft Azure
Building Custom Visual Studio Team Service Build Tasks With VSTS DevOps Task SDK
Building a Continuous Delivery Pipeline With Visual Studio
Going Serverless with Azure Functions #1 - Introduction to Azure Functions
Making Money with Technology
Monetizing Windows Phone Apps

Recently uploaded (20)

PDF
4K Video Downloader Crack + License Key 2025
PDF
IObit Driver Booster Pro Crack Latest Version Download
PPTX
Hexagone difital twin solution in the desgining
PDF
How to Write Automated Test Scripts Using Selenium.pdf
PPTX
MCP empowers AI Agents from Zero to Production
PPTX
Greedy best-first search algorithm always selects the path which appears best...
PDF
Software Development Company - swapdigit | Best Mobile App Development In India
PPTX
ESDS_SAP Application Cloud Offerings.pptx
PPTX
SIH2024_IDEA_dy_dx_deepfakedetection.pptx
PPTX
SQL introduction and commands, SQL joining
PDF
MaterialX Virtual Town Hall - August 2025
PDF
10 Mistakes Agile Project Managers Still Make
PDF
Difference Between Website and Web Application.pdf
PPTX
Presentation - Summer Internship at Samatrix.io_template_2.pptx
PPT
introduction of sql, sql commands(DD,DML,DCL))
PPTX
Beige and Black Minimalist Project Deck Presentation (1).pptx
PDF
solman-7.0-ehp1-sp21-incident-management
PPTX
Independent Consultants’ Biggest Challenges in ERP Projects – and How Apagen ...
PDF
Science is Not Enough SPLC2009 Richard P. Gabriel
PDF
IDM Crack Activation Key 2025 Free Download
4K Video Downloader Crack + License Key 2025
IObit Driver Booster Pro Crack Latest Version Download
Hexagone difital twin solution in the desgining
How to Write Automated Test Scripts Using Selenium.pdf
MCP empowers AI Agents from Zero to Production
Greedy best-first search algorithm always selects the path which appears best...
Software Development Company - swapdigit | Best Mobile App Development In India
ESDS_SAP Application Cloud Offerings.pptx
SIH2024_IDEA_dy_dx_deepfakedetection.pptx
SQL introduction and commands, SQL joining
MaterialX Virtual Town Hall - August 2025
10 Mistakes Agile Project Managers Still Make
Difference Between Website and Web Application.pdf
Presentation - Summer Internship at Samatrix.io_template_2.pptx
introduction of sql, sql commands(DD,DML,DCL))
Beige and Black Minimalist Project Deck Presentation (1).pptx
solman-7.0-ehp1-sp21-incident-management
Independent Consultants’ Biggest Challenges in ERP Projects – and How Apagen ...
Science is Not Enough SPLC2009 Richard P. Gabriel
IDM Crack Activation Key 2025 Free Download

Better End-to-End Testing with Page Objects Model using Protractor

  • 1. Better End-to-End Testing With Page Object Model Using Protractor Kasun Kodagoda | Team Finale Trainee Software Engineer | 99X Technology
  • 2. Overview ‱ Protractor ‱ What is it? ‱ Getting Up and Running ‱ Basic Requirements ‱ Page Objects ‱ What is it? ‱ Why Use it? ‱ A Deeper Dive.. ‱ Demo
  • 4. What Is It? “Protractor is an end-to-end test framework for AngularJS applications. Protractor runs tests against your application running in a real browser, interacting with it as a user would” Source: Official Protractor Website
  • 5. What Is It? ‱ Combination of powerful technologies and tools for testing Node.js, Selenium, Jasmine, WebDriver, Cucumber, Mocha ‱ Wrapper for Selenium, made for Angular.js ‱ Uses angular specific constructs for capturing elements Model, bindings, repeaters etc. ‱ Runs on real browsers as well as headless browsers
  • 6. Get Up And Running.. ‱ Install Node.js ‱ Install Protractor npm install –g protractor ‱ Install WebDriver webdriver-manager update ‱ Start WebDriver webdriver-manager start // do this before you run the tests
  • 7. Basic Requirements ‱ You’ll need 2 basic files to start, ‱ A Test/Spec file Contains the element references, assertions ‱ The Configuration File Contains the configuration options for running protractor ‱ Use your preferred test framework to write tests ‱ Jasmine – Fully Supported ‱ Mocha – Limited Support ‱ Cucumber – Limited Support
  • 8. Sample Config File exports.config = { seleniumAddress: 'http://localhost:4444/wd/hub', capabilities: { 'browserName': 'chrome' }, specs: [ 'specs/*Spec.js' ], jasmineNodeOpts: { showColors: true } };
  • 9. Sample Test describe('Test Home Page', function () { it("Should display the text typed in to the input field.", function () { browser.get('http://localhost:8080/#/'); // Type in a value to input field var textInput = element(by.model('sampleInput')); textInput.sendKeys('The KVK Blog'); // Check if the same value is displayed var displayField = element(by.binding('sampleInput')); expect(displayField.getText()).toEqual('The KVK Blog'); }); });
  • 10. Conventional UI Tests ‱ Element references are inside tests ‱ Test are cluttered ‱ Less readable ‱ Very fragile
  • 12. What Is A Page Object? “A page object is an object-oriented class that serves as an interface to a page of your AUT” ‱ Wraps a HTML page/fragment ‱ Provide Application Specific API ‱ Hides the underlying complexity ‱ Used to manipulate elements on page
  • 13. Why Use Page Objects? ‱ Reduce Code Duplication ‱ Reusable Page Objects ‱ More Readable Tests ‱ Less Vulnerable to Break ‱ More Maintainable Tests Especially in Agile Based Projects
  • 14. A Deeper Dive
 Return Types ‱ Methods in Page Objects should return fundamental types Strings, Dates, Booleans ‱ It can return other complex types as well Promises, other Page Objects
  • 15. A Deeper Dive
 ‱ Method names can be much closer to what the user is actually doing. var inputField = element(by.model(‘first_name’); inputField.sendKeys(‘Kasun’); Or element(by.model(‘first_name’)).sendKeys(‘Kasun’); Instead We can use somePage.addFirstName(‘Kasun’);
  • 16. A Deeper Dive
 The Dilemma ‱ Use of assertions ‱ Include Assertions inside Page Objects ‱ Not Include Assertions inside Page Objects ‱ It’s Subjective and the Choice is yours

  • 17. A Deeper Dive
 No Assertions in Page Objects for Us. Why?? ‱ Separation of Responsibility ‱ Page Objects should only provide access to HTML pages ‱ Page Objects become longer
  • 18. A Deeper Dive
 What We Believe “If what we test changes, The assertions and the tests should change” “If the HTML page changes, The Page Object should change” This, ‱ Allows us to easily modify the tests/specs when functionality or underlying HTML pages change overtime
  • 20. You Have NO Questions
 Right?... ;)
  • 21. Thank You For Not Throwing Rocks At Me ^_^