SlideShare a Scribd company logo
THE BATTLE OF CYPRESS & PROTRACTOR
AGENDA
Installation
Onboarding to the framework
Configuration
API differences:
● actions
● assertions
● waiton’s
Parallelization
Debugging
Testing types (api/unit/e2e)
Project size
Performance
Multi platform
Reporting
WHO ARE YOU?
● https://valor-software.com/ngx-bootstrap/#/
● https://github.com/ludmilanesvitiy
● https://www.linkedin.com/in/ludmila-nesvitiy-58094ab7/
● https://valor-software.com/persons/ludmila-nesvitiy
● https://twitter.com/LudmilaNes
3+YRS
AUTOMATED
TESTING
10+N
YEARS IN IT
CURRENT
PROJECT
OPEN
SOURCE
NGX-BOOTSTRAP
Native Angular widgets for Bootstrap 3 & 4.
~600,000 npm downloads per month
Designed documentation view
Created custom UI elements:
https://github.com/ludmilanesvitiy/RunIT-TestProject
INSTALLATION
Protractor Cypress
Recommend to install locally in project
npm install cypress --save-dev
./node_modules/.bin/cypress open
Recommend to install globally to your machine
npm install -g protractor
webdriver-manager update
INSTALLATION
ONBOARDING TO THE FRAMEWORK
Protractor Cypress
Main basic goal - easy testing any app
./node_modules/.bin/cypress open
Main basic goal - easy testing Angular apps
ng new YourProjectName
ONBOARDING
ONBOARDING TO THE PROTRACTOR
ng new YourProjectName
ONBOARDING
ONBOARDING TO THE CYPRESS
npm install cypress --save-dev
ONBOARDING
./node_modules/.bin/cypress open
CONFIGURATION
Protractor Cypress
tsconfig.json //TODOtsconfig.e2e.json
cypress.json //TODOprotractor.conf.js
CONFIGURATION
CONFIGURATION
protractor.conf.js
CONFIGURATION
CONFIGURATION
cypress.json
{}
CONFIGURATION
CONFIGURATION
cypress.json
CONFIGURATION
COMPARISON TABLE
API DIFFERENCES
Protractor Cypress
Global browser cy
Navigate the page get() visit()
Trigger click event click() click()
Type in input smth sendKeys() type()
Clear input clear() clear()
Mouse actions, events actions() trigger()
Keyboard event sendKeys(protractor.Key.ESCAPE) type('{esc}', { force: true })
Reload current page refresh() reload()
COMPARISON TABLE
API DIFFERENCES
Protractor Cypress
Find element element(by.css(‘’)) / $ get(‘’)
Find elements array element.all(by.css(‘’)) / $$ get(‘’)
Take N web-element from array first(), last(), get(N) first(), last(), eq(N)
Assign element to const / create alias const a = $(‘’); get(‘’).as(‘const_a’);
Find element with text element(by.cssContainingText(‘’)) get(‘’).contains();
Take each element from array each() each()
Wait for an arbitrary period sleep(N) wait(N)
Get current URL browser.getCurrentUrl() cy.hash()
ASSERTIONS COMPARISON
API DIFFERENCES
Protractor Cypress
Element shown on the page expect(e.isDisplayed()).toBe(true); e.should(‘be.visible’);
Element selected expect(isSelected()).toBe(true); e.should(‘be.selected’);
Element text appropriate expect(e.getText()).toEqual(‘’); e.invoke(‘text’).should(...)
Element attribute appropriate expect(e.getAttribute(‘a’)).toEqual(‘’); e.should(‘have.attr’, ‘value’)
Element css appropriate expect(e.getCssValue(‘’)).toEqual(‘’); e.should(‘have.css’, ‘value’)
Elements array length appropriate expect(array.count()).toEqual(N) e.should(‘to.have.length, N)
ASSERTIONS COMPARISON
API DIFFERENCES
$(`input`).then(input => {
expect(input.getAttribute('value')).toContain(expectedTxt);
});
vs
cy.get(`input`).then(input => {
expect(input.val()).to.contains(expectedTxt);
});
cy.get(`input`).should(`have.val`, expectedTxt);
TEST ARCHITECTURE
API DIFFERENCES
BaseComponent
DatePickerPO SortablePO ...
Test1 Test2 TestN...
FILE STRUCTURE
API DIFFERENCES
support
- base.component.ts
- datepicker.po.ts
- …
- sortable.po.ts
integration
- Test 1
- Test 2
- …
- Test N
TEST STRUCTURE
Protractor Cypress
import { DatepickerPo } from '../support/datepicker.po';
describe('Datepicker demo page test suite', () => {
const datepicker = new DatepickerPo();
const basic = datepicker.exampleDemosArr.basic;
beforeEach(async () => await datepicker.navigateTo());
it('when user clicks on "Datepicker" input, container with 2 arrows:
"‹", "›" opened, no one date selected', async () => {
await datepicker.clickOnDatepickerInput(basic);
await datepicker.isSelectedDateExist('datepicker', false);
await datepicker.isDatepickerNavigationFullyActiveAndCorrect('date');
});
});
import { DatepickerPo } from '../support/datepicker.po';
describe('Datepicker demo page test suite', () => {
const datepicker = new DatepickerPo();
const basic = datepicker.exampleDemosArr.basic;
beforeEach(() => datepicker.navigateTo());
it('when user clicks on "Datepicker" input, container with 2 arrows:
"‹", "›" opened, no one date selected', () => {
datepicker.clickOnDatepickerInput(basic);
datepicker.isSelectedDateExist('datepicker', false);
datepicker.isDatepickerNavigationFullyActiveAndCorrect('date');
});
});
API DIFFERENCES
BASE PAGE OBJECT
API DIFFERENCES
Protractor Cypress
export abstract class BaseComponent {
abstract pageUrl: string;
async navigateTo() {
await browser.get(`${ this.pageUrl }`);
}
}
export abstract class BaseComponent {
abstract pageUrl: string;
navigateTo() {
cy.visit(`${ this.pageUrl }`);
}
}
BASE PAGE OBJECT
API DIFFERENCES
Protractor Cypress
async clickOnDemoMenu(subMenu: string) {
await element(by.cssContainingText(
'add-nav a', subMenu))
.click();
}
clickOnDemoMenu(subMenu: string) {
cy.get('add-nav')
.contains('a', subMenu)
.click();
}
BASE PAGE OBJECT
API DIFFERENCES
Protractor Cypress
async clearInputAndSendKeys(
baseSelector: string,
dataToSend: string,
inputIndex = 0) {
const input = $$(`${baseSelector} input`)
.get(inputIndex);
await input.clear();
await input.sendKeys(dataToSend);
}
clearInputAndSendKeys(
baseSelector: string,
dataToSend: string,
inputIndex = 0) {
cy.get(`${baseSelector} input`)
.eq(inputIndex)
.clear()
.type(dataToSend);
}
BASE PAGE OBJECT
API DIFFERENCES
Protractor Cypress
async clickEnterOnInput(
baseSelector: string,
inputIndex = 0) {
await browser
.actions({bridge: true})
.sendKeys(protractor.Key.ENTER)
.perform();
}
clickEnterOnInput(
baseSelector: string,
inputIndex = 0) {
cy.get(`${baseSelector} input`)
.eq(inputIndex)
.type('{enter}');
}
WAIT-ON’S
API DIFFERENCES
Protractor Cypress
ExpectedConditions
● not
● and
● or
● alertIsPresent
● elementToBeClickable
● textToBePresentInElement
● textToBePresentInElementValue
● titleContains
● titleIs
● urlContains
● urlIs
● presenceOf
● stalenessOf
● visibilityOf
● invisibilityOf
● elementToBeSelected
It’s all retry-
ability
WAIT-ON’S
API DIFFERENCES
Protractor Cypress
ExpectedConditions
● not
● and
● or
● alertIsPresent
● elementToBeClickable
● textToBePresentInElement
● textToBePresentInElementValue
● titleContains
● titleIs
● urlContains
● urlIs
● presenceOf
● stalenessOf
● visibilityOf
● invisibilityOf
● elementToBeSelected
1. Retry all, except .click()
2. Retry up to 4 sec (defaultCommandTimeout)
3. Wait for route
cy.route('routeName/*').as('routeAlias');
cy.wait(['@routeAlias'], 10000);
PARALLELIZATION
Protractor Cypress
cypress run --record --key=NNN --parallel
shardTestFiles: true,
maxInstances: N
PARALLELIZATION
TESTING TYPES
Protractor Cypress
e2ee2e
API tests:
https://github.com/cypress-io/cypress-example-api-testing
https://docs.cypress.io/api/commands/request.html
API tests:
https://www.npmjs.com/package/request
unit:
https://github.com/bahmutov/cypress-angular-unit-test
TESTING TYPES
PROJECT SIZE
PROJECT SIZE
PERFORMANCE
58 tests, absolutely identical logic (depend on available API)
Protractor, Chrome visible Cypress open
~~2 m 45 sec~~ 52 sec
Protractor, Chrome headless Cypress run
~~1 m 8 sec~~ 43 sec
PERFORMANCE
CPU LOADING - PROTRACTOR, CHROME
PERFORMANCE
CPU LOADING - CYPRESS OPEN
PERFORMANCE
MULTI PLATFORM
Protractor Cypress
Canary, Chrome, Chromium, ElectronChrome, Firefox, Safari, and IE
Full info:
https://docs.cypress.io/guides/core-concepts/launching-
browsers.html#
Full list:
http://www.protractortest.org/#/browser-support
MULTI PLATFORM
REPORTING
Protractor Cypress
mocha reporters: https://mochajs.org/#reporters
teamcity
junit
{
"reporter": "junit",
"reporterOptions": {
}
}
jasmine-spec-reporter
protractor-jasmine2-screenshot-reporter
protractor-html-reporter-2
protractor-beautiful-reporter
protractor-zephyr-reporter
jasmine-protractor-reporter
protractor-jasmine2-html-reporter
onPrepare: function () {
jasmine.getEnv().addReporter(...)
}
REPORTING
Dashboard
REPORTING - Protractor
REPORTING
REPORTING - Cypress
REPORTING
REPORTING - Cypress
REPORTING
DEBUGGING
Protractor Cypress
cypress open
.debug()
cy.pause()
https://docs.cypress.io/guides/guides/debugging.html
add to appropriate place:
debugger;
add appropriate breakpoints
node --inspect-brk ./node_modules/.bin/protractor
protractor/protractor.conf.js
go to browser and enter:
chrome://inspect/#devices
click on Open dedicated DevTools for Node
click on “Play” and investigate results
https://www.protractortest.org/#/debugging
DEBUGGING
DEBUGGING
STATISTICS
SUMMARY
Installation
Onboarding to the framework
Configuration
API differences
Parallelization
Debugging
Testing types (api/unit/e2e)
Project size
Performance
Multi platform
Reporting
USEFUL LINKS
● https://github.com/ludmilanesvitiy/RunIT-TestProject
● https://github.com/cypress-io/cypress-example-api-testing
● https://docs.cypress.io/api/commands/request.html
● https://github.com/bahmutov/cypress-angular-unit-test
● https://mochajs.org/#reporters
● https://docs.cypress.io/guides/guides/debugging.html
● https://docs.cypress.io/guides/core-concepts/launching-browsers.html#
● https://www.npmjs.com/package/request
● http://www.protractortest.org/#/browser-support
● https://www.protractortest.org/#/debugging
● https://valor-software.com/persons/ludmila-nesvitiy

More Related Content

What's hot

Angular.js Primer in Aalto University
Angular.js Primer in Aalto UniversityAngular.js Primer in Aalto University
Angular.js Primer in Aalto University
SC5.io
 
AngularJs Crash Course
AngularJs Crash CourseAngularJs Crash Course
AngularJs Crash Course
Keith Bloomfield
 
AngularJS Basics with Example
AngularJS Basics with ExampleAngularJS Basics with Example
AngularJS Basics with Example
Sergey Bolshchikov
 
Crossing platforms with JavaScript & React
Crossing platforms with JavaScript & React Crossing platforms with JavaScript & React
Crossing platforms with JavaScript & React
Robert DeLuca
 
JavaScript Unit Testing with Jasmine
JavaScript Unit Testing with JasmineJavaScript Unit Testing with Jasmine
JavaScript Unit Testing with Jasmine
Raimonds Simanovskis
 
Angular - injection tokens & Custom libraries
Angular - injection tokens & Custom librariesAngular - injection tokens & Custom libraries
Angular - injection tokens & Custom libraries
Eliran Eliassy
 
Upgrading from Angular 1.x to Angular 2.x
Upgrading from Angular 1.x to Angular 2.xUpgrading from Angular 1.x to Angular 2.x
Upgrading from Angular 1.x to Angular 2.x
Eyal Vardi
 
Developing A Real World Logistic Application With Oracle Application - UKOUG ...
Developing A Real World Logistic Application With Oracle Application - UKOUG ...Developing A Real World Logistic Application With Oracle Application - UKOUG ...
Developing A Real World Logistic Application With Oracle Application - UKOUG ...Roel Hartman
 
Method and decorator
Method and decoratorMethod and decorator
Method and decorator
Celine George
 
Angular js 2.0, ng poznań 20.11
Angular js 2.0, ng poznań 20.11Angular js 2.0, ng poznań 20.11
Angular js 2.0, ng poznań 20.11
Kamil Augustynowicz
 
Testing your javascript code with jasmine
Testing your javascript code with jasmineTesting your javascript code with jasmine
Testing your javascript code with jasmineRubyc Slides
 
AngularJS Framework
AngularJS FrameworkAngularJS Framework
AngularJS Framework
Barcamp Saigon
 
Angular 2.0 - What to expect
Angular 2.0 - What to expectAngular 2.0 - What to expect
Angular 2.0 - What to expect
Allan Marques Baptista
 
Solid angular
Solid angularSolid angular
Solid angular
Nir Kaufman
 
Exploring Angular 2 - Episode 2
Exploring Angular 2 - Episode 2Exploring Angular 2 - Episode 2
Exploring Angular 2 - Episode 2
Ahmed Moawad
 
How Angular2 Can Improve Your AngularJS Apps Today!
How Angular2 Can Improve Your AngularJS Apps Today!How Angular2 Can Improve Your AngularJS Apps Today!
How Angular2 Can Improve Your AngularJS Apps Today!
Nir Kaufman
 
Angularjs Basics
Angularjs BasicsAngularjs Basics
Angularjs Basics
Anuradha Bandara
 
An introduction to Angular2
An introduction to Angular2 An introduction to Angular2
An introduction to Angular2
Apptension
 
ngMess: AngularJS Dependency Injection
ngMess: AngularJS Dependency InjectionngMess: AngularJS Dependency Injection
ngMess: AngularJS Dependency Injection
Dzmitry Ivashutsin
 

What's hot (20)

Angular.js Primer in Aalto University
Angular.js Primer in Aalto UniversityAngular.js Primer in Aalto University
Angular.js Primer in Aalto University
 
AngularJs Crash Course
AngularJs Crash CourseAngularJs Crash Course
AngularJs Crash Course
 
AngularJS Basics with Example
AngularJS Basics with ExampleAngularJS Basics with Example
AngularJS Basics with Example
 
Crossing platforms with JavaScript & React
Crossing platforms with JavaScript & React Crossing platforms with JavaScript & React
Crossing platforms with JavaScript & React
 
JavaScript Unit Testing with Jasmine
JavaScript Unit Testing with JasmineJavaScript Unit Testing with Jasmine
JavaScript Unit Testing with Jasmine
 
Angular - injection tokens & Custom libraries
Angular - injection tokens & Custom librariesAngular - injection tokens & Custom libraries
Angular - injection tokens & Custom libraries
 
Upgrading from Angular 1.x to Angular 2.x
Upgrading from Angular 1.x to Angular 2.xUpgrading from Angular 1.x to Angular 2.x
Upgrading from Angular 1.x to Angular 2.x
 
Developing A Real World Logistic Application With Oracle Application - UKOUG ...
Developing A Real World Logistic Application With Oracle Application - UKOUG ...Developing A Real World Logistic Application With Oracle Application - UKOUG ...
Developing A Real World Logistic Application With Oracle Application - UKOUG ...
 
Method and decorator
Method and decoratorMethod and decorator
Method and decorator
 
Angular js 2.0, ng poznań 20.11
Angular js 2.0, ng poznań 20.11Angular js 2.0, ng poznań 20.11
Angular js 2.0, ng poznań 20.11
 
Testing your javascript code with jasmine
Testing your javascript code with jasmineTesting your javascript code with jasmine
Testing your javascript code with jasmine
 
AngularJS Framework
AngularJS FrameworkAngularJS Framework
AngularJS Framework
 
Angular 2.0 - What to expect
Angular 2.0 - What to expectAngular 2.0 - What to expect
Angular 2.0 - What to expect
 
Solid angular
Solid angularSolid angular
Solid angular
 
Exploring Angular 2 - Episode 2
Exploring Angular 2 - Episode 2Exploring Angular 2 - Episode 2
Exploring Angular 2 - Episode 2
 
How Angular2 Can Improve Your AngularJS Apps Today!
How Angular2 Can Improve Your AngularJS Apps Today!How Angular2 Can Improve Your AngularJS Apps Today!
How Angular2 Can Improve Your AngularJS Apps Today!
 
Angularjs Basics
Angularjs BasicsAngularjs Basics
Angularjs Basics
 
08 Queries
08 Queries08 Queries
08 Queries
 
An introduction to Angular2
An introduction to Angular2 An introduction to Angular2
An introduction to Angular2
 
ngMess: AngularJS Dependency Injection
ngMess: AngularJS Dependency InjectionngMess: AngularJS Dependency Injection
ngMess: AngularJS Dependency Injection
 

Similar to The battle of Protractor and Cypress - RunIT Conference 2019

Tamir Dresher - What’s new in ASP.NET Core 6
Tamir Dresher - What’s new in ASP.NET Core 6Tamir Dresher - What’s new in ASP.NET Core 6
Tamir Dresher - What’s new in ASP.NET Core 6
Tamir Dresher
 
Reduxing like a pro
Reduxing like a proReduxing like a pro
Reduxing like a pro
Boris Dinkevich
 
Serverless Angular, Material, Firebase and Google Cloud applications
Serverless Angular, Material, Firebase and Google Cloud applicationsServerless Angular, Material, Firebase and Google Cloud applications
Serverless Angular, Material, Firebase and Google Cloud applications
Loiane Groner
 
Automation in angular js
Automation in angular jsAutomation in angular js
Automation in angular js
Marcin Wosinek
 
Angular server side rendering - Strategies & Technics
Angular server side rendering - Strategies & Technics Angular server side rendering - Strategies & Technics
Angular server side rendering - Strategies & Technics
Eliran Eliassy
 
Maciej Treder "Server-side rendering with Angular—be faster and more SEO, CDN...
Maciej Treder "Server-side rendering with Angular—be faster and more SEO, CDN...Maciej Treder "Server-side rendering with Angular—be faster and more SEO, CDN...
Maciej Treder "Server-side rendering with Angular—be faster and more SEO, CDN...
Fwdays
 
Protractor framework – how to make stable e2e tests for Angular applications
Protractor framework – how to make stable e2e tests for Angular applicationsProtractor framework – how to make stable e2e tests for Angular applications
Protractor framework – how to make stable e2e tests for Angular applications
Ludmila Nesvitiy
 
The use case of a scalable architecture
The use case of a scalable architectureThe use case of a scalable architecture
The use case of a scalable architecture
Toru Wonyoung Choi
 
Angular 4 for Java Developers
Angular 4 for Java DevelopersAngular 4 for Java Developers
Angular 4 for Java Developers
Yakov Fain
 
Node.js: scalability tips - Azure Dev Community Vijayawada
Node.js: scalability tips - Azure Dev Community VijayawadaNode.js: scalability tips - Azure Dev Community Vijayawada
Node.js: scalability tips - Azure Dev Community Vijayawada
Luciano Mammino
 
Wcf data services
Wcf data servicesWcf data services
Wcf data services
Eyal Vardi
 
mobl
moblmobl
mobl
zefhemel
 
React native app with type script tutorial
React native app with type script tutorialReact native app with type script tutorial
React native app with type script tutorial
Katy Slemon
 
Restful Web Service
Restful Web ServiceRestful Web Service
Restful Web Service
Bin Cai
 
Practical AngularJS
Practical AngularJSPractical AngularJS
Practical AngularJS
Wei Ru
 
WordPress Realtime - WordCamp São Paulo 2015
WordPress Realtime - WordCamp São Paulo 2015WordPress Realtime - WordCamp São Paulo 2015
WordPress Realtime - WordCamp São Paulo 2015
Fernando Daciuk
 
Durable functions 2.0 (2019-10-10)
Durable functions 2.0 (2019-10-10)Durable functions 2.0 (2019-10-10)
Durable functions 2.0 (2019-10-10)
Paco de la Cruz
 
前端MVC 豆瓣说
前端MVC 豆瓣说前端MVC 豆瓣说
前端MVC 豆瓣说Ting Lv
 
Academy PRO: React native - building first scenes
Academy PRO: React native - building first scenesAcademy PRO: React native - building first scenes
Academy PRO: React native - building first scenes
Binary Studio
 
Coding Ajax
Coding AjaxCoding Ajax
Coding Ajax
Ted Husted
 

Similar to The battle of Protractor and Cypress - RunIT Conference 2019 (20)

Tamir Dresher - What’s new in ASP.NET Core 6
Tamir Dresher - What’s new in ASP.NET Core 6Tamir Dresher - What’s new in ASP.NET Core 6
Tamir Dresher - What’s new in ASP.NET Core 6
 
Reduxing like a pro
Reduxing like a proReduxing like a pro
Reduxing like a pro
 
Serverless Angular, Material, Firebase and Google Cloud applications
Serverless Angular, Material, Firebase and Google Cloud applicationsServerless Angular, Material, Firebase and Google Cloud applications
Serverless Angular, Material, Firebase and Google Cloud applications
 
Automation in angular js
Automation in angular jsAutomation in angular js
Automation in angular js
 
Angular server side rendering - Strategies & Technics
Angular server side rendering - Strategies & Technics Angular server side rendering - Strategies & Technics
Angular server side rendering - Strategies & Technics
 
Maciej Treder "Server-side rendering with Angular—be faster and more SEO, CDN...
Maciej Treder "Server-side rendering with Angular—be faster and more SEO, CDN...Maciej Treder "Server-side rendering with Angular—be faster and more SEO, CDN...
Maciej Treder "Server-side rendering with Angular—be faster and more SEO, CDN...
 
Protractor framework – how to make stable e2e tests for Angular applications
Protractor framework – how to make stable e2e tests for Angular applicationsProtractor framework – how to make stable e2e tests for Angular applications
Protractor framework – how to make stable e2e tests for Angular applications
 
The use case of a scalable architecture
The use case of a scalable architectureThe use case of a scalable architecture
The use case of a scalable architecture
 
Angular 4 for Java Developers
Angular 4 for Java DevelopersAngular 4 for Java Developers
Angular 4 for Java Developers
 
Node.js: scalability tips - Azure Dev Community Vijayawada
Node.js: scalability tips - Azure Dev Community VijayawadaNode.js: scalability tips - Azure Dev Community Vijayawada
Node.js: scalability tips - Azure Dev Community Vijayawada
 
Wcf data services
Wcf data servicesWcf data services
Wcf data services
 
mobl
moblmobl
mobl
 
React native app with type script tutorial
React native app with type script tutorialReact native app with type script tutorial
React native app with type script tutorial
 
Restful Web Service
Restful Web ServiceRestful Web Service
Restful Web Service
 
Practical AngularJS
Practical AngularJSPractical AngularJS
Practical AngularJS
 
WordPress Realtime - WordCamp São Paulo 2015
WordPress Realtime - WordCamp São Paulo 2015WordPress Realtime - WordCamp São Paulo 2015
WordPress Realtime - WordCamp São Paulo 2015
 
Durable functions 2.0 (2019-10-10)
Durable functions 2.0 (2019-10-10)Durable functions 2.0 (2019-10-10)
Durable functions 2.0 (2019-10-10)
 
前端MVC 豆瓣说
前端MVC 豆瓣说前端MVC 豆瓣说
前端MVC 豆瓣说
 
Academy PRO: React native - building first scenes
Academy PRO: React native - building first scenesAcademy PRO: React native - building first scenes
Academy PRO: React native - building first scenes
 
Coding Ajax
Coding AjaxCoding Ajax
Coding Ajax
 

Recently uploaded

Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
SOFTTECHHUB
 
RESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for studentsRESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for students
KAMESHS29
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
UiPathCommunity
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
Jemma Hussein Allen
 
By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024
Pierluigi Pugliese
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
Guy Korland
 
The Metaverse and AI: how can decision-makers harness the Metaverse for their...
The Metaverse and AI: how can decision-makers harness the Metaverse for their...The Metaverse and AI: how can decision-makers harness the Metaverse for their...
The Metaverse and AI: how can decision-makers harness the Metaverse for their...
Jen Stirrup
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
91mobiles
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
Alan Dix
 
Enhancing Performance with Globus and the Science DMZ
Enhancing Performance with Globus and the Science DMZEnhancing Performance with Globus and the Science DMZ
Enhancing Performance with Globus and the Science DMZ
Globus
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
Ralf Eggert
 
UiPath Community Day Dubai: AI at Work..
UiPath Community Day Dubai: AI at Work..UiPath Community Day Dubai: AI at Work..
UiPath Community Day Dubai: AI at Work..
UiPathCommunity
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
Kari Kakkonen
 
Assure Contact Center Experiences for Your Customers With ThousandEyes
Assure Contact Center Experiences for Your Customers With ThousandEyesAssure Contact Center Experiences for Your Customers With ThousandEyes
Assure Contact Center Experiences for Your Customers With ThousandEyes
ThousandEyes
 
Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
Dorra BARTAGUIZ
 
Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
Adtran
 
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to ProductionGenerative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Aggregage
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
Prayukth K V
 

Recently uploaded (20)

Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
 
RESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for studentsRESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for students
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
 
By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
 
The Metaverse and AI: how can decision-makers harness the Metaverse for their...
The Metaverse and AI: how can decision-makers harness the Metaverse for their...The Metaverse and AI: how can decision-makers harness the Metaverse for their...
The Metaverse and AI: how can decision-makers harness the Metaverse for their...
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
 
Enhancing Performance with Globus and the Science DMZ
Enhancing Performance with Globus and the Science DMZEnhancing Performance with Globus and the Science DMZ
Enhancing Performance with Globus and the Science DMZ
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
 
UiPath Community Day Dubai: AI at Work..
UiPath Community Day Dubai: AI at Work..UiPath Community Day Dubai: AI at Work..
UiPath Community Day Dubai: AI at Work..
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
 
Assure Contact Center Experiences for Your Customers With ThousandEyes
Assure Contact Center Experiences for Your Customers With ThousandEyesAssure Contact Center Experiences for Your Customers With ThousandEyes
Assure Contact Center Experiences for Your Customers With ThousandEyes
 
Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
 
Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
 
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to ProductionGenerative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to Production
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
 

The battle of Protractor and Cypress - RunIT Conference 2019

  • 1. THE BATTLE OF CYPRESS & PROTRACTOR
  • 2. AGENDA Installation Onboarding to the framework Configuration API differences: ● actions ● assertions ● waiton’s Parallelization Debugging Testing types (api/unit/e2e) Project size Performance Multi platform Reporting
  • 3. WHO ARE YOU? ● https://valor-software.com/ngx-bootstrap/#/ ● https://github.com/ludmilanesvitiy ● https://www.linkedin.com/in/ludmila-nesvitiy-58094ab7/ ● https://valor-software.com/persons/ludmila-nesvitiy ● https://twitter.com/LudmilaNes 3+YRS AUTOMATED TESTING 10+N YEARS IN IT CURRENT PROJECT OPEN SOURCE
  • 4. NGX-BOOTSTRAP Native Angular widgets for Bootstrap 3 & 4. ~600,000 npm downloads per month Designed documentation view Created custom UI elements: https://github.com/ludmilanesvitiy/RunIT-TestProject
  • 5. INSTALLATION Protractor Cypress Recommend to install locally in project npm install cypress --save-dev ./node_modules/.bin/cypress open Recommend to install globally to your machine npm install -g protractor webdriver-manager update INSTALLATION
  • 6. ONBOARDING TO THE FRAMEWORK Protractor Cypress Main basic goal - easy testing any app ./node_modules/.bin/cypress open Main basic goal - easy testing Angular apps ng new YourProjectName ONBOARDING
  • 7. ONBOARDING TO THE PROTRACTOR ng new YourProjectName ONBOARDING
  • 8.
  • 9. ONBOARDING TO THE CYPRESS npm install cypress --save-dev ONBOARDING
  • 11.
  • 12.
  • 17. COMPARISON TABLE API DIFFERENCES Protractor Cypress Global browser cy Navigate the page get() visit() Trigger click event click() click() Type in input smth sendKeys() type() Clear input clear() clear() Mouse actions, events actions() trigger() Keyboard event sendKeys(protractor.Key.ESCAPE) type('{esc}', { force: true }) Reload current page refresh() reload()
  • 18. COMPARISON TABLE API DIFFERENCES Protractor Cypress Find element element(by.css(‘’)) / $ get(‘’) Find elements array element.all(by.css(‘’)) / $$ get(‘’) Take N web-element from array first(), last(), get(N) first(), last(), eq(N) Assign element to const / create alias const a = $(‘’); get(‘’).as(‘const_a’); Find element with text element(by.cssContainingText(‘’)) get(‘’).contains(); Take each element from array each() each() Wait for an arbitrary period sleep(N) wait(N) Get current URL browser.getCurrentUrl() cy.hash()
  • 19. ASSERTIONS COMPARISON API DIFFERENCES Protractor Cypress Element shown on the page expect(e.isDisplayed()).toBe(true); e.should(‘be.visible’); Element selected expect(isSelected()).toBe(true); e.should(‘be.selected’); Element text appropriate expect(e.getText()).toEqual(‘’); e.invoke(‘text’).should(...) Element attribute appropriate expect(e.getAttribute(‘a’)).toEqual(‘’); e.should(‘have.attr’, ‘value’) Element css appropriate expect(e.getCssValue(‘’)).toEqual(‘’); e.should(‘have.css’, ‘value’) Elements array length appropriate expect(array.count()).toEqual(N) e.should(‘to.have.length, N)
  • 20. ASSERTIONS COMPARISON API DIFFERENCES $(`input`).then(input => { expect(input.getAttribute('value')).toContain(expectedTxt); }); vs cy.get(`input`).then(input => { expect(input.val()).to.contains(expectedTxt); }); cy.get(`input`).should(`have.val`, expectedTxt);
  • 22. FILE STRUCTURE API DIFFERENCES support - base.component.ts - datepicker.po.ts - … - sortable.po.ts integration - Test 1 - Test 2 - … - Test N
  • 23. TEST STRUCTURE Protractor Cypress import { DatepickerPo } from '../support/datepicker.po'; describe('Datepicker demo page test suite', () => { const datepicker = new DatepickerPo(); const basic = datepicker.exampleDemosArr.basic; beforeEach(async () => await datepicker.navigateTo()); it('when user clicks on "Datepicker" input, container with 2 arrows: "‹", "›" opened, no one date selected', async () => { await datepicker.clickOnDatepickerInput(basic); await datepicker.isSelectedDateExist('datepicker', false); await datepicker.isDatepickerNavigationFullyActiveAndCorrect('date'); }); }); import { DatepickerPo } from '../support/datepicker.po'; describe('Datepicker demo page test suite', () => { const datepicker = new DatepickerPo(); const basic = datepicker.exampleDemosArr.basic; beforeEach(() => datepicker.navigateTo()); it('when user clicks on "Datepicker" input, container with 2 arrows: "‹", "›" opened, no one date selected', () => { datepicker.clickOnDatepickerInput(basic); datepicker.isSelectedDateExist('datepicker', false); datepicker.isDatepickerNavigationFullyActiveAndCorrect('date'); }); }); API DIFFERENCES
  • 24. BASE PAGE OBJECT API DIFFERENCES Protractor Cypress export abstract class BaseComponent { abstract pageUrl: string; async navigateTo() { await browser.get(`${ this.pageUrl }`); } } export abstract class BaseComponent { abstract pageUrl: string; navigateTo() { cy.visit(`${ this.pageUrl }`); } }
  • 25. BASE PAGE OBJECT API DIFFERENCES Protractor Cypress async clickOnDemoMenu(subMenu: string) { await element(by.cssContainingText( 'add-nav a', subMenu)) .click(); } clickOnDemoMenu(subMenu: string) { cy.get('add-nav') .contains('a', subMenu) .click(); }
  • 26. BASE PAGE OBJECT API DIFFERENCES Protractor Cypress async clearInputAndSendKeys( baseSelector: string, dataToSend: string, inputIndex = 0) { const input = $$(`${baseSelector} input`) .get(inputIndex); await input.clear(); await input.sendKeys(dataToSend); } clearInputAndSendKeys( baseSelector: string, dataToSend: string, inputIndex = 0) { cy.get(`${baseSelector} input`) .eq(inputIndex) .clear() .type(dataToSend); }
  • 27. BASE PAGE OBJECT API DIFFERENCES Protractor Cypress async clickEnterOnInput( baseSelector: string, inputIndex = 0) { await browser .actions({bridge: true}) .sendKeys(protractor.Key.ENTER) .perform(); } clickEnterOnInput( baseSelector: string, inputIndex = 0) { cy.get(`${baseSelector} input`) .eq(inputIndex) .type('{enter}'); }
  • 28. WAIT-ON’S API DIFFERENCES Protractor Cypress ExpectedConditions ● not ● and ● or ● alertIsPresent ● elementToBeClickable ● textToBePresentInElement ● textToBePresentInElementValue ● titleContains ● titleIs ● urlContains ● urlIs ● presenceOf ● stalenessOf ● visibilityOf ● invisibilityOf ● elementToBeSelected It’s all retry- ability
  • 29. WAIT-ON’S API DIFFERENCES Protractor Cypress ExpectedConditions ● not ● and ● or ● alertIsPresent ● elementToBeClickable ● textToBePresentInElement ● textToBePresentInElementValue ● titleContains ● titleIs ● urlContains ● urlIs ● presenceOf ● stalenessOf ● visibilityOf ● invisibilityOf ● elementToBeSelected 1. Retry all, except .click() 2. Retry up to 4 sec (defaultCommandTimeout) 3. Wait for route cy.route('routeName/*').as('routeAlias'); cy.wait(['@routeAlias'], 10000);
  • 30. PARALLELIZATION Protractor Cypress cypress run --record --key=NNN --parallel shardTestFiles: true, maxInstances: N PARALLELIZATION
  • 31. TESTING TYPES Protractor Cypress e2ee2e API tests: https://github.com/cypress-io/cypress-example-api-testing https://docs.cypress.io/api/commands/request.html API tests: https://www.npmjs.com/package/request unit: https://github.com/bahmutov/cypress-angular-unit-test TESTING TYPES
  • 33. PERFORMANCE 58 tests, absolutely identical logic (depend on available API) Protractor, Chrome visible Cypress open ~~2 m 45 sec~~ 52 sec Protractor, Chrome headless Cypress run ~~1 m 8 sec~~ 43 sec PERFORMANCE
  • 34. CPU LOADING - PROTRACTOR, CHROME PERFORMANCE
  • 35. CPU LOADING - CYPRESS OPEN PERFORMANCE
  • 36. MULTI PLATFORM Protractor Cypress Canary, Chrome, Chromium, ElectronChrome, Firefox, Safari, and IE Full info: https://docs.cypress.io/guides/core-concepts/launching- browsers.html# Full list: http://www.protractortest.org/#/browser-support MULTI PLATFORM
  • 37. REPORTING Protractor Cypress mocha reporters: https://mochajs.org/#reporters teamcity junit { "reporter": "junit", "reporterOptions": { } } jasmine-spec-reporter protractor-jasmine2-screenshot-reporter protractor-html-reporter-2 protractor-beautiful-reporter protractor-zephyr-reporter jasmine-protractor-reporter protractor-jasmine2-html-reporter onPrepare: function () { jasmine.getEnv().addReporter(...) } REPORTING Dashboard
  • 41. DEBUGGING Protractor Cypress cypress open .debug() cy.pause() https://docs.cypress.io/guides/guides/debugging.html add to appropriate place: debugger; add appropriate breakpoints node --inspect-brk ./node_modules/.bin/protractor protractor/protractor.conf.js go to browser and enter: chrome://inspect/#devices click on Open dedicated DevTools for Node click on “Play” and investigate results https://www.protractortest.org/#/debugging DEBUGGING
  • 42.
  • 45. SUMMARY Installation Onboarding to the framework Configuration API differences Parallelization Debugging Testing types (api/unit/e2e) Project size Performance Multi platform Reporting
  • 46. USEFUL LINKS ● https://github.com/ludmilanesvitiy/RunIT-TestProject ● https://github.com/cypress-io/cypress-example-api-testing ● https://docs.cypress.io/api/commands/request.html ● https://github.com/bahmutov/cypress-angular-unit-test ● https://mochajs.org/#reporters ● https://docs.cypress.io/guides/guides/debugging.html ● https://docs.cypress.io/guides/core-concepts/launching-browsers.html# ● https://www.npmjs.com/package/request ● http://www.protractortest.org/#/browser-support ● https://www.protractortest.org/#/debugging ● https://valor-software.com/persons/ludmila-nesvitiy