SlideShare a Scribd company logo
UI Testing with Protractor 
Andrew Eisenberg 
Tasktop Technologies
About me 
• PhD from UBC 
• SpringSource/VMware/Pivotal 
– Spring, Groovy, AspectJ, JS (IDE and languages) 
• Tasktop 
– Platform and Apps teams
Kinds of testing 
• Unit testing 
• Integration testing 
– UI Testing 
• System testing 
Using Protractor
How Protractor works 
• Selenium Server to manage browsers 
• Selenium WebDriver to invoke browser APIs 
• Protractor node app to run tests 
• Jasmine, etc as test framework
How to run Protractor 
• Protractor config file: 
exports.config = { 
onPrepare: function () { … }, 
capabilities: {'browserName’:'firefox’}, 
specs: ['../tests/*.spec.js'], 
baseUrl: 'http://localhost:8080/’, 
jasmineNodeOpts: { … }, 
// and many more options 
} 
• To launch: 
protractor protractor.conf.js
The first test 
describe('HomePage', function () { 
it('should be the default page', 
function () { 
browser.get(browser.baseUrl); 
expect(browser 
.getCurrentUrl()) 
.toEqual(browser.baseUrl 
+ 'projectsinfo'); 
}); 
});
The PageObject pattern 
• Models the services exported by a page 
LoginPage.prototype = { 
isLoggedIn : function() { … }, 
logout : function() { … }, 
login : function() { … }, 
cancelLogin : function() { … } 
}
Secretly, everything is a promise
Debugging! 
Add to script: 
browser.debugger(); 
Launch in debug mode: 
protractor debug protractor.conf.js
SOME THINGS I LEARNED
Avoid complex selectors 
Bad 
element(by.cssContainingText(‘table.data tr.user td.name’, 
‘Jane’); 
element(by.repeater(‘option as option.label for option in 
field.options track by (option.value + option.label)’); 
Good 
element(by.cssContainingText(‘.name’, ‘Jane’); 
element(by.css (‘#name-Jane’); 
element(by.css(‘#options’));
Selectors are brittle 
• ids most stable 
– easy to fix when they change 
– consider dynamically generated ids 
• but be careful they are always valid and unique 
– Should be namespaced by directive 
• but…what if directive repeated multiple times? 
• OK to refactor base code 
– make it more testable 
– expose ids
Impossible to test everything 
• Too many corner cases 
• Happy path 
• A few corner cases 
• Any interesting interactions 
• More complex tests are more brittle 
• Trade-off: 
– time spent writing/maintaining tests vs code
Your tests will be 
Incomplete and 
Brittle 
Deal with it.
State & Reproducibility 
• Better to test against clean state 
• Better to tear down before each test 
• Can be slow to clean 
• Tests should not make assumptions about 
clean state
UI Testing with Protractor 
Andrew Eisenberg 
Twitter: @werdnagreb

More Related Content

What's hot (20)

Automated Web Testing using JavaScript
Automated Web Testing using JavaScript
Simon Guest
 
Protractor overview
Protractor overview
Abhishek Yadav
 
Protractor end-to-end testing framework for angular js
Protractor end-to-end testing framework for angular js
codeandyou forums
 
Workshop - E2e tests with protractor
Workshop - E2e tests with protractor
Walmyr Lima e Silva Filho
 
Protractor for angularJS
Protractor for angularJS
Krishna Kumar
 
Marcin Wasilczyk - Page objects with selenium
Marcin Wasilczyk - Page objects with selenium
Trójmiejska Grupa Testerska
 
Automated Smoke Tests with Protractor
Automated Smoke Tests with Protractor
🌱 Dale Spoonemore
 
Automated Testing using JavaScript
Automated Testing using JavaScript
Simon Guest
 
Join the darkside: Selenium testing with Nightwatch.js
Join the darkside: Selenium testing with Nightwatch.js
Seth McLaughlin
 
Insights on Protractor testing
Insights on Protractor testing
Dejan Toteff
 
Browser Automated Testing Frameworks - Nightwatch.js
Browser Automated Testing Frameworks - Nightwatch.js
Luís Bastião Silva
 
Jellyfish, JSCONF 2011
Jellyfish, JSCONF 2011
Adam Christian
 
TestingAR XX - Protractor e2e Test Framework - Introduction what we have lear...
TestingAR XX - Protractor e2e Test Framework - Introduction what we have lear...
TestingAR Meetup
 
Automated Testing in Angular Slides
Automated Testing in Angular Slides
Jim Lynch
 
Introduction to Protractor
Introduction to Protractor
Florian Fesseler
 
Automated Testing with Cucumber, PhantomJS and Selenium
Automated Testing with Cucumber, PhantomJS and Selenium
Dev9Com
 
Testing nightwatch, by David Torroija
Testing nightwatch, by David Torroija
David Torroija
 
Webdriver.io
Webdriver.io
LinkMe Srl
 
Automation using Javascript
Automation using Javascript
khanhdang1214
 
Development of automated tests for ext js based web sites
Development of automated tests for ext js based web sites
ISsoft
 
Automated Web Testing using JavaScript
Automated Web Testing using JavaScript
Simon Guest
 
Protractor end-to-end testing framework for angular js
Protractor end-to-end testing framework for angular js
codeandyou forums
 
Protractor for angularJS
Protractor for angularJS
Krishna Kumar
 
Automated Smoke Tests with Protractor
Automated Smoke Tests with Protractor
🌱 Dale Spoonemore
 
Automated Testing using JavaScript
Automated Testing using JavaScript
Simon Guest
 
Join the darkside: Selenium testing with Nightwatch.js
Join the darkside: Selenium testing with Nightwatch.js
Seth McLaughlin
 
Insights on Protractor testing
Insights on Protractor testing
Dejan Toteff
 
Browser Automated Testing Frameworks - Nightwatch.js
Browser Automated Testing Frameworks - Nightwatch.js
Luís Bastião Silva
 
Jellyfish, JSCONF 2011
Jellyfish, JSCONF 2011
Adam Christian
 
TestingAR XX - Protractor e2e Test Framework - Introduction what we have lear...
TestingAR XX - Protractor e2e Test Framework - Introduction what we have lear...
TestingAR Meetup
 
Automated Testing in Angular Slides
Automated Testing in Angular Slides
Jim Lynch
 
Introduction to Protractor
Introduction to Protractor
Florian Fesseler
 
Automated Testing with Cucumber, PhantomJS and Selenium
Automated Testing with Cucumber, PhantomJS and Selenium
Dev9Com
 
Testing nightwatch, by David Torroija
Testing nightwatch, by David Torroija
David Torroija
 
Automation using Javascript
Automation using Javascript
khanhdang1214
 
Development of automated tests for ext js based web sites
Development of automated tests for ext js based web sites
ISsoft
 

Viewers also liked (20)

Introduction to Protractor
Introduction to Protractor
Jie-Wei Wu
 
Protractor powerpoint
Protractor powerpoint
lindarousselle
 
Sharing the pain using Protractor
Sharing the pain using Protractor
Anand Bagmar
 
Testing in AngularJS
Testing in AngularJS
Peter Drinnan
 
Triangles
Triangles
sawanttara
 
Classifying Triangles
Classifying Triangles
Amanda Casto
 
Triangle and its properties
Triangle and its properties
yas5
 
Around The World In 80 Days
Around The World In 80 Days
Nor Fadzleen
 
Load Testing with JMeter
Load Testing with JMeter
Yuriy Gerasimov
 
Angularjs - Unit testing introduction
Angularjs - Unit testing introduction
Nir Kaufman
 
Apache JMeter - A brief introduction
Apache JMeter - A brief introduction
silenceIT Inc.
 
How to Analyze Reports in Jmeter
How to Analyze Reports in Jmeter
Viviana Lesmes
 
Performance testing and reporting with JMeter
Performance testing and reporting with JMeter
jvSlideshare
 
Get Hip with JHipster: Spring Boot + AngularJS + Bootstrap - DOSUG February 2016
Get Hip with JHipster: Spring Boot + AngularJS + Bootstrap - DOSUG February 2016
Matt Raible
 
Sun, Moon, And Earth Powerpoint
Sun, Moon, And Earth Powerpoint
Cheryl Plainte
 
Perils of Page-Object Pattern
Perils of Page-Object Pattern
Anand Bagmar
 
Test Data - Food for your Test Automation Framework
Test Data - Food for your Test Automation Framework
Anand Bagmar
 
Interpreting Performance Test Results
Interpreting Performance Test Results
Eric Proegler
 
Triangle and its properties
Triangle and its properties
Azam Khan
 
Types of Polygons
Types of Polygons
Fortune Shara Radin
 
Introduction to Protractor
Introduction to Protractor
Jie-Wei Wu
 
Sharing the pain using Protractor
Sharing the pain using Protractor
Anand Bagmar
 
Testing in AngularJS
Testing in AngularJS
Peter Drinnan
 
Classifying Triangles
Classifying Triangles
Amanda Casto
 
Triangle and its properties
Triangle and its properties
yas5
 
Around The World In 80 Days
Around The World In 80 Days
Nor Fadzleen
 
Load Testing with JMeter
Load Testing with JMeter
Yuriy Gerasimov
 
Angularjs - Unit testing introduction
Angularjs - Unit testing introduction
Nir Kaufman
 
Apache JMeter - A brief introduction
Apache JMeter - A brief introduction
silenceIT Inc.
 
How to Analyze Reports in Jmeter
How to Analyze Reports in Jmeter
Viviana Lesmes
 
Performance testing and reporting with JMeter
Performance testing and reporting with JMeter
jvSlideshare
 
Get Hip with JHipster: Spring Boot + AngularJS + Bootstrap - DOSUG February 2016
Get Hip with JHipster: Spring Boot + AngularJS + Bootstrap - DOSUG February 2016
Matt Raible
 
Sun, Moon, And Earth Powerpoint
Sun, Moon, And Earth Powerpoint
Cheryl Plainte
 
Perils of Page-Object Pattern
Perils of Page-Object Pattern
Anand Bagmar
 
Test Data - Food for your Test Automation Framework
Test Data - Food for your Test Automation Framework
Anand Bagmar
 
Interpreting Performance Test Results
Interpreting Performance Test Results
Eric Proegler
 
Triangle and its properties
Triangle and its properties
Azam Khan
 
Ad

Similar to Angular UI Testing with Protractor (20)

Protractor End To End Testing For AngularJS
Protractor End To End Testing For AngularJS
Knoldus Inc.
 
Protractor framework architecture with example
Protractor framework architecture with example
shadabgilani
 
Moving from selenium to protractor for test automation
Moving from selenium to protractor for test automation
Zoe Gilbert
 
Protractor Testing Automation Tool Framework / Jasmine Reporters
Protractor Testing Automation Tool Framework / Jasmine Reporters
Haitham Refaat
 
Sharing (less) Pain of using Protractor & WebDriver
Sharing (less) Pain of using Protractor & WebDriver
Anand Bagmar
 
Protractor framework – how to make stable e2e tests for Angular applications
Protractor framework – how to make stable e2e tests for Angular applications
Ludmila Nesvitiy
 
Сергей Больщиков "Protractor Tips & Tricks"
Сергей Больщиков "Protractor Tips & Tricks"
Fwdays
 
Using protractor to build automated ui tests
Using protractor to build automated ui tests
🌱 Dale Spoonemore
 
Knowledge of web ui for automation testing
Knowledge of web ui for automation testing
Artem Korchevyi
 
QA Fes 2016. Александр Хотемской. Обзор ProtractorJS как фреймворка для брауз...
QA Fes 2016. Александр Хотемской. Обзор ProtractorJS как фреймворка для брауз...
QAFest
 
Protractor Training - Online training On Skype
Protractor Training - Online training On Skype
QuickITDotNet Training and Services
 
Protractor Training in Pune by QuickITDotnet
Protractor Training in Pune by QuickITDotnet
QuickITDotNet Training and Services
 
ProtractorJS for automated testing of Angular 1.x/2.x applications
ProtractorJS for automated testing of Angular 1.x/2.x applications
Binary Studio
 
Presentation_Protractor
Presentation_Protractor
Umesh Randhe
 
Олександр Хотемський “ProtractorJS як інструмент браузерної автоматизації для...
Олександр Хотемський “ProtractorJS як інструмент браузерної автоматизації для...
Dakiry
 
Introduction to Protractor - Habilelabs
Introduction to Protractor - Habilelabs
HabileLabs
 
ForwardJS 2017 - Fullstack end-to-end Test Automation with node.js
ForwardJS 2017 - Fullstack end-to-end Test Automation with node.js
Mek Srunyu Stittri
 
Angular js automation using protractor
Angular js automation using protractor
Ravi Gupta
 
Increase selenium tests stability via java script
Increase selenium tests stability via java script
Igor Khrol
 
Effective testing of rich internet applications
Effective testing of rich internet applications
Rashwin
 
Protractor End To End Testing For AngularJS
Protractor End To End Testing For AngularJS
Knoldus Inc.
 
Protractor framework architecture with example
Protractor framework architecture with example
shadabgilani
 
Moving from selenium to protractor for test automation
Moving from selenium to protractor for test automation
Zoe Gilbert
 
Protractor Testing Automation Tool Framework / Jasmine Reporters
Protractor Testing Automation Tool Framework / Jasmine Reporters
Haitham Refaat
 
Sharing (less) Pain of using Protractor & WebDriver
Sharing (less) Pain of using Protractor & WebDriver
Anand Bagmar
 
Protractor framework – how to make stable e2e tests for Angular applications
Protractor framework – how to make stable e2e tests for Angular applications
Ludmila Nesvitiy
 
Сергей Больщиков "Protractor Tips & Tricks"
Сергей Больщиков "Protractor Tips & Tricks"
Fwdays
 
Using protractor to build automated ui tests
Using protractor to build automated ui tests
🌱 Dale Spoonemore
 
Knowledge of web ui for automation testing
Knowledge of web ui for automation testing
Artem Korchevyi
 
QA Fes 2016. Александр Хотемской. Обзор ProtractorJS как фреймворка для брауз...
QA Fes 2016. Александр Хотемской. Обзор ProtractorJS как фреймворка для брауз...
QAFest
 
ProtractorJS for automated testing of Angular 1.x/2.x applications
ProtractorJS for automated testing of Angular 1.x/2.x applications
Binary Studio
 
Presentation_Protractor
Presentation_Protractor
Umesh Randhe
 
Олександр Хотемський “ProtractorJS як інструмент браузерної автоматизації для...
Олександр Хотемський “ProtractorJS як інструмент браузерної автоматизації для...
Dakiry
 
Introduction to Protractor - Habilelabs
Introduction to Protractor - Habilelabs
HabileLabs
 
ForwardJS 2017 - Fullstack end-to-end Test Automation with node.js
ForwardJS 2017 - Fullstack end-to-end Test Automation with node.js
Mek Srunyu Stittri
 
Angular js automation using protractor
Angular js automation using protractor
Ravi Gupta
 
Increase selenium tests stability via java script
Increase selenium tests stability via java script
Igor Khrol
 
Effective testing of rich internet applications
Effective testing of rich internet applications
Rashwin
 
Ad

Recently uploaded (20)

AI and Deep Learning with NVIDIA Technologies
AI and Deep Learning with NVIDIA Technologies
SandeepKS52
 
Shell Skill Tree - LabEx Certification (LabEx)
Shell Skill Tree - LabEx Certification (LabEx)
VICTOR MAESTRE RAMIREZ
 
How the US Navy Approaches DevSecOps with Raise 2.0
How the US Navy Approaches DevSecOps with Raise 2.0
Anchore
 
Agile Software Engineering Methodologies
Agile Software Engineering Methodologies
Gaurav Sharma
 
Wondershare PDFelement Pro 11.4.20.3548 Crack Free Download
Wondershare PDFelement Pro 11.4.20.3548 Crack Free Download
Puppy jhon
 
Migrating to Azure Cosmos DB the Right Way
Migrating to Azure Cosmos DB the Right Way
Alexander (Alex) Komyagin
 
Artificial Intelligence Applications Across Industries
Artificial Intelligence Applications Across Industries
SandeepKS52
 
Application Modernization with Choreo - The AI-Native Internal Developer Plat...
Application Modernization with Choreo - The AI-Native Internal Developer Plat...
WSO2
 
Step by step guide to install Flutter and Dart
Step by step guide to install Flutter and Dart
S Pranav (Deepu)
 
OpenTelemetry 101 Cloud Native Barcelona
OpenTelemetry 101 Cloud Native Barcelona
Imma Valls Bernaus
 
Women in Tech: Marketo Engage User Group - June 2025 - AJO with AWS
Women in Tech: Marketo Engage User Group - June 2025 - AJO with AWS
BradBedford3
 
Milwaukee Marketo User Group June 2025 - Optimize and Enhance Efficiency - Sm...
Milwaukee Marketo User Group June 2025 - Optimize and Enhance Efficiency - Sm...
BradBedford3
 
UPDASP a project coordination unit ......
UPDASP a project coordination unit ......
withrj1
 
Smart Financial Solutions: Money Lender Software, Daily Pigmy & Personal Loan...
Smart Financial Solutions: Money Lender Software, Daily Pigmy & Personal Loan...
Intelli grow
 
Neuralink Templateeeeeeeeeeeeeeeeeeeeeeeeee
Neuralink Templateeeeeeeeeeeeeeeeeeeeeeeeee
alexandernoetzold
 
Zoneranker’s Digital marketing solutions
Zoneranker’s Digital marketing solutions
reenashriee
 
What is data visualization and how data visualization tool can help.pdf
What is data visualization and how data visualization tool can help.pdf
Varsha Nayak
 
wAIred_RabobankIgniteSession_12062025.pptx
wAIred_RabobankIgniteSession_12062025.pptx
SimonedeGijt
 
Who will create the languages of the future?
Who will create the languages of the future?
Jordi Cabot
 
Open Source Software Development Methods
Open Source Software Development Methods
VICTOR MAESTRE RAMIREZ
 
AI and Deep Learning with NVIDIA Technologies
AI and Deep Learning with NVIDIA Technologies
SandeepKS52
 
Shell Skill Tree - LabEx Certification (LabEx)
Shell Skill Tree - LabEx Certification (LabEx)
VICTOR MAESTRE RAMIREZ
 
How the US Navy Approaches DevSecOps with Raise 2.0
How the US Navy Approaches DevSecOps with Raise 2.0
Anchore
 
Agile Software Engineering Methodologies
Agile Software Engineering Methodologies
Gaurav Sharma
 
Wondershare PDFelement Pro 11.4.20.3548 Crack Free Download
Wondershare PDFelement Pro 11.4.20.3548 Crack Free Download
Puppy jhon
 
Artificial Intelligence Applications Across Industries
Artificial Intelligence Applications Across Industries
SandeepKS52
 
Application Modernization with Choreo - The AI-Native Internal Developer Plat...
Application Modernization with Choreo - The AI-Native Internal Developer Plat...
WSO2
 
Step by step guide to install Flutter and Dart
Step by step guide to install Flutter and Dart
S Pranav (Deepu)
 
OpenTelemetry 101 Cloud Native Barcelona
OpenTelemetry 101 Cloud Native Barcelona
Imma Valls Bernaus
 
Women in Tech: Marketo Engage User Group - June 2025 - AJO with AWS
Women in Tech: Marketo Engage User Group - June 2025 - AJO with AWS
BradBedford3
 
Milwaukee Marketo User Group June 2025 - Optimize and Enhance Efficiency - Sm...
Milwaukee Marketo User Group June 2025 - Optimize and Enhance Efficiency - Sm...
BradBedford3
 
UPDASP a project coordination unit ......
UPDASP a project coordination unit ......
withrj1
 
Smart Financial Solutions: Money Lender Software, Daily Pigmy & Personal Loan...
Smart Financial Solutions: Money Lender Software, Daily Pigmy & Personal Loan...
Intelli grow
 
Neuralink Templateeeeeeeeeeeeeeeeeeeeeeeeee
Neuralink Templateeeeeeeeeeeeeeeeeeeeeeeeee
alexandernoetzold
 
Zoneranker’s Digital marketing solutions
Zoneranker’s Digital marketing solutions
reenashriee
 
What is data visualization and how data visualization tool can help.pdf
What is data visualization and how data visualization tool can help.pdf
Varsha Nayak
 
wAIred_RabobankIgniteSession_12062025.pptx
wAIred_RabobankIgniteSession_12062025.pptx
SimonedeGijt
 
Who will create the languages of the future?
Who will create the languages of the future?
Jordi Cabot
 
Open Source Software Development Methods
Open Source Software Development Methods
VICTOR MAESTRE RAMIREZ
 

Angular UI Testing with Protractor

  • 1. UI Testing with Protractor Andrew Eisenberg Tasktop Technologies
  • 2. About me • PhD from UBC • SpringSource/VMware/Pivotal – Spring, Groovy, AspectJ, JS (IDE and languages) • Tasktop – Platform and Apps teams
  • 3. Kinds of testing • Unit testing • Integration testing – UI Testing • System testing Using Protractor
  • 4. How Protractor works • Selenium Server to manage browsers • Selenium WebDriver to invoke browser APIs • Protractor node app to run tests • Jasmine, etc as test framework
  • 5. How to run Protractor • Protractor config file: exports.config = { onPrepare: function () { … }, capabilities: {'browserName’:'firefox’}, specs: ['../tests/*.spec.js'], baseUrl: 'http://localhost:8080/’, jasmineNodeOpts: { … }, // and many more options } • To launch: protractor protractor.conf.js
  • 6. The first test describe('HomePage', function () { it('should be the default page', function () { browser.get(browser.baseUrl); expect(browser .getCurrentUrl()) .toEqual(browser.baseUrl + 'projectsinfo'); }); });
  • 7. The PageObject pattern • Models the services exported by a page LoginPage.prototype = { isLoggedIn : function() { … }, logout : function() { … }, login : function() { … }, cancelLogin : function() { … } }
  • 9. Debugging! Add to script: browser.debugger(); Launch in debug mode: protractor debug protractor.conf.js
  • 10. SOME THINGS I LEARNED
  • 11. Avoid complex selectors Bad element(by.cssContainingText(‘table.data tr.user td.name’, ‘Jane’); element(by.repeater(‘option as option.label for option in field.options track by (option.value + option.label)’); Good element(by.cssContainingText(‘.name’, ‘Jane’); element(by.css (‘#name-Jane’); element(by.css(‘#options’));
  • 12. Selectors are brittle • ids most stable – easy to fix when they change – consider dynamically generated ids • but be careful they are always valid and unique – Should be namespaced by directive • but…what if directive repeated multiple times? • OK to refactor base code – make it more testable – expose ids
  • 13. Impossible to test everything • Too many corner cases • Happy path • A few corner cases • Any interesting interactions • More complex tests are more brittle • Trade-off: – time spent writing/maintaining tests vs code
  • 14. Your tests will be Incomplete and Brittle Deal with it.
  • 15. State & Reproducibility • Better to test against clean state • Better to tear down before each test • Can be slow to clean • Tests should not make assumptions about clean state
  • 16. UI Testing with Protractor Andrew Eisenberg Twitter: @werdnagreb