SlideShare uma empresa Scribd logo
1 de 21
Protractor
By: Syed Shadab Gilani
Introduction
 Protractor, formally known as E2E testing framework, is an open source functional automation framework designed
specifically for AngularJS web applications. It was introduced during AngularJS 1.2 as a replacement of the existing E2E
testing framework. The Protractor automation tool is also recommended by AngularJS for scenario testing.
 For an angular app functional automation framework to automate the UI and functionality of the web application, we zeroed
in on the Protractor automation tool.
Features
 Built on the top of WebdriverJS and Selenium server
 Introduced new simple syntax to write tests
 Allows running tests targeting remote addresses
 Can take advantage of Selenium grid to run multiple browsers at once
 Can use Jasmine or Mocha to write test suites
Benefits
 Protractor is a wrapper (built on the top) around Selenium WebDriver, so it contains every feature that is available in the
Selenium WebDriver. Additionally, Protractor provides some new locator strategies and functions which are very helpful to
automate the AngularJS application. Examples include things like: waitForAngular, By.binding, By.repeater, By.textarea,
By.model, WebElement.all, WebElement.evaluate, etc.
Installation
Pre Requisite:
 Download and install NodeJS. http://nodejs.org/download/. After installation make sure its path is configured correctly, so
that command execution can find Node.
Installation…
 Open the command prompt and type in the following command to install protractor globally.
- npm install –g protractor
 Install Protractor Locally
You can install protractor locally in your project directory. Go to your project directory and type in the following command in the command
prompt:
- npm install protractor
 Verify Installation
To verify your installation, please type in the command
- Protractor –version
 If Protractor is installed successfully then the system will display the installed version. Otherwise you will have to recheck the installation.
 If you don’t have the Selenium server on your machine, then download the latest version onto your machine. If you want to run tests on different
browsers, then please download the respective drivers as well. For example, Chrome driver will come in handy to run tests on the Chrome browser.
Architecture of Framework
Pages : Contains pages and elements(Locators)
CommonUtils: Contains common methods or operations used for UI and API automation
TestData : Contains constant value and payload in case of API automation
Specs: Contains scenario - test cases
Conf : Contains configuration and capabilities
Reports : Allure reporting - screenshots and reports
TestLogs : Contains logs
Pages Example
"use strict";
//Importing required files
var data = require('../TestData/TestData.json');
var commonCode = require('../CommonUtils/CommonCode.js')
var elementsPage = require('../CommonUtils/ElementsPage.js');
var log4js = require('log4js');
var logger = log4js.getLogger();
var XYZPage = function () {
var EC = protractor.ExpectedConditions;
// Login to the application
this.loginInToTheApplication = async function (userNameElement,userName,passwordElement, password) {
try {
commonCode.wait_tillVisible(elementsPage.adminEmailTextbox);
commonCode.sendDataToTextBox(userNameElement,userName);
commonCode.sendDataToTextBox(passwordElement, password);
commonCode.clickAction(elementsPage.loginButton);
commonCode.wait_tillVisible(elementsPage.someTitle);
expect(elementsPage.someTitle.isDisplayed()).toBe(true);
} catch (e) {
logger.error('Error while Logging in to the application' + e.message);
}
};
};
module.exports = new XYZPage();
It is used for UI automation.
Common Code Example
// To perform Click operation
this.clickAction = async function (element) {
try {
this.wait_tillClickable(element);
this.highlightElement(element);
element.click();
} catch (e) {
logger.error('Error while clicking on the web element' +
e.message);
}
};
For UI
Common Code Example
// Get method with cookie
this.getMethodWithCookie = async function (IP, PATH,
COOKIE) {
const expect = chai.expect;
const chaiHttp1 = chai.request(IP);
const response = await chaiHttp1.get(PATH).set(COOKIE);
return response;
};
For API
Elements File Example
"use strict";
var ElementsPage = function () {
//landingPage
this.xyz_button = element.all(by.css('input[value*="xyz"]')).get(0);
this.emailTextbox = element(by.css('input[placeholder*="E-mail
Address"]'));
this.passwordTextbox = element(by.css('input[placeholder*="Password"]'));
this.loginButton = element(by.css('button[class*="btn-login-btn"]'));
};
module.exports = new ElementsPage();
Test Data Example
{
"comments": " // Login Credentials",
“url": "http://abc.net/",
”userName": abc,
“password": "123",
}
Specs File Example
"use strict";
//Importing required files
var data = require('../TestData/TestData.json');
var commonCode = require('../CommonUtils/CommonCode.js')
var elementsPage = require('../CommonUtils/ElementsPage.js');
var landingPage = require('../Pages/LandingPage.js');
//* Login scenario for XYZ automation
describe("Login for XYZ - ", function () {
beforeAll(function () {
commonCode.appInitialization(data["url"]);
});
it("Login to the portal", async function () {
abcPage.loginInToTheApplication(elementsPage.emailTextbox,data["username"],elementsPage.passwordTextbox,data
["password"]);
});
});
For UI
Specs File Example
"use strict";
// Importing necessary plugins and required files
var chai = require('chai'),
chaiHttp = require('chai-http');
chai.use(chaiHttp);
var data = require('../TestData/TestData.json');
var commonCode = require('../CommonUtils/CommonCode.js')
var elementsPage = require('../CommonUtils/ElementsPage.js');
// Sample API scenarios
describe("Sample Api test cases - ", function () {
beforeAll(function () {
commonCode.appInitialization(data["adminURL"]);
commonCode.getCookie();
browser.sleep(10000);
});
// Get method with cookie sample
it("GET method with cookie", async function () {
const expect = chai.expect;
await commonCode.getMethodWithCookie(IP, Path, global.cookie).then(function (response) {
console.log(JSON.stringify(response));
console.log(response.status);
console.log(JSON.stringify(response.body));
global.DataOne = response.body.dataOne;
console.log('dataOne : ', response.body.dataOne);
expect(response).to.have.status(data.successStatusCode);
});
});
});
For API
Conf File Example
"use strict";
const log4js = require('log4js');
log4js.configure({
appenders: {
everything: {
type: 'file',
filename:
'testLogs/Execution_Logs_Consolidated.log',
maxLogSize: 10485760,
backups: 3,
compress: true
}
},
categories: {
default: {
appenders: ['everything'],
level: 'debug'
}
}
});
exports.config = {
// Browser use
capabilities: {
'browserName': 'chrome',
//'chromeOptions': {
//'args': ["no-sandbox", "--headless", "--disable-gpu",
"--window-size=800x600"]
//}
},
// Framework selection
framework: 'jasmine2',
// Executing a single test case - "protractor Config.js"
specs: ['./Specs/SampleSpecs.js'],
// Executing suite - "protractor Config.js --suite
spec1,spec2"
suites: {
spec1: [
'Specs/FirstSpecs.js'
],
spec2: [
'Specs/SecondSpecs.js'
]
},
Conf File Example
jasmineNodeOpts: {
showColors: true,
defaultTimeoutInterval: 400000,
isVerbose: true,
includeStackTrace: true
},
onPrepare: function () {
var AllureReporter = require('jasmine-allure-reporter');
jasmine.getEnv().addReporter(new AllureReporter({
allureReport: {
resultsDir: 'allure-results'
}
}));
jasmine.getEnv().afterEach(function (done) {
browser.takeScreenshot().then(function (png) {
allure.createAttachment('Screenshot', function () {
return new Buffer(png, 'base64');
}, 'image/png')();
done();
});
});
}
};
Allure Reporting
 For Windows, Allure is available from the Scoop commandline-installer.
 To install Allure, download and install Scoop and then execute in the Powershell:
- scoop install allure
 Also Scoop is capable of updating Allure distribution installations. To do so navigate to the Scoop installation directory and
execute
 bincheckver.ps1 allure -u
 This will check for newer versions of Allure, and update the manifest file. Then execute
- scoop update allure
Alternate commands….
 Using Allure Command Line Tool
 Add the allure-commandline dependency in your current project by running the below command.
- npm install allure-commandline --save-dev
Some Useful NPM commands
 Installing node modules : npm install
 Downgrade npm to specific version: npm install –g npm@2
 Check npm version: npm –version
 Install package locally: npm install package_name
 Install package locally and make an entry in package.json as dependency : npm install package_name --save
 List installed packages: npm ls
 Update npm: npm update
 Clean npm cache: npm cache clean –f
………….
Protractor framework architecture with example
Protractor framework architecture with example

Mais conteúdo relacionado

Mais procurados

Intro to testing Javascript with jasmine
Intro to testing Javascript with jasmineIntro to testing Javascript with jasmine
Intro to testing Javascript with jasmineTimothy Oxley
 
Intro to Unit Testing in AngularJS
Intro to Unit Testing in AngularJSIntro to Unit Testing in AngularJS
Intro to Unit Testing in AngularJSJim Lynch
 
Test Driven Development with JavaFX
Test Driven Development with JavaFXTest Driven Development with JavaFX
Test Driven Development with JavaFXHendrik Ebbers
 
Unit testing in JavaScript with Jasmine and Karma
Unit testing in JavaScript with Jasmine and KarmaUnit testing in JavaScript with Jasmine and Karma
Unit testing in JavaScript with Jasmine and KarmaAndrey Kolodnitsky
 
Angularjs - Unit testing introduction
Angularjs - Unit testing introductionAngularjs - Unit testing introduction
Angularjs - Unit testing introductionNir Kaufman
 
Test like a pro with Ember.js
Test like a pro with Ember.jsTest like a pro with Ember.js
Test like a pro with Ember.jsMike North
 
JavaScript TDD with Jasmine and Karma
JavaScript TDD with Jasmine and KarmaJavaScript TDD with Jasmine and Karma
JavaScript TDD with Jasmine and KarmaChristopher Bartling
 
Rapid prototyping and easy testing with ember cli mirage
Rapid prototyping and easy testing with ember cli mirageRapid prototyping and easy testing with ember cli mirage
Rapid prototyping and easy testing with ember cli mirageKrzysztof Bialek
 
Unit testing of java script and angularjs application using Karma Jasmine Fra...
Unit testing of java script and angularjs application using Karma Jasmine Fra...Unit testing of java script and angularjs application using Karma Jasmine Fra...
Unit testing of java script and angularjs application using Karma Jasmine Fra...Samyak Bhalerao
 
Reactive Streams and RxJava2
Reactive Streams and RxJava2Reactive Streams and RxJava2
Reactive Streams and RxJava2Yakov Fain
 
Ember testing internals with ember cli
Ember testing internals with ember cliEmber testing internals with ember cli
Ember testing internals with ember cliCory Forsyth
 
Quick tour to front end unit testing using jasmine
Quick tour to front end unit testing using jasmineQuick tour to front end unit testing using jasmine
Quick tour to front end unit testing using jasmineGil Fink
 
#11.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_국비지원학원,재직자/실업자교육학원,스프링교육,마이바...
#11.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_국비지원학원,재직자/실업자교육학원,스프링교육,마이바...#11.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_국비지원학원,재직자/실업자교육학원,스프링교육,마이바...
#11.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_국비지원학원,재직자/실업자교육학원,스프링교육,마이바...탑크리에듀(구로디지털단지역3번출구 2분거리)
 
Unit testing JavaScript: Jasmine & karma intro
Unit testing JavaScript: Jasmine & karma introUnit testing JavaScript: Jasmine & karma intro
Unit testing JavaScript: Jasmine & karma introMaurice De Beijer [MVP]
 
Django Celery - A distributed task queue
Django Celery - A distributed task queueDjango Celery - A distributed task queue
Django Celery - A distributed task queueAlex Eftimie
 
Testing Ember Apps: Managing Dependency
Testing Ember Apps: Managing DependencyTesting Ember Apps: Managing Dependency
Testing Ember Apps: Managing DependencyMatthew Beale
 

Mais procurados (20)

Vuejs testing
Vuejs testingVuejs testing
Vuejs testing
 
Intro to testing Javascript with jasmine
Intro to testing Javascript with jasmineIntro to testing Javascript with jasmine
Intro to testing Javascript with jasmine
 
Intro to Unit Testing in AngularJS
Intro to Unit Testing in AngularJSIntro to Unit Testing in AngularJS
Intro to Unit Testing in AngularJS
 
Full Stack Unit Testing
Full Stack Unit TestingFull Stack Unit Testing
Full Stack Unit Testing
 
Test Driven Development with JavaFX
Test Driven Development with JavaFXTest Driven Development with JavaFX
Test Driven Development with JavaFX
 
Unit testing in JavaScript with Jasmine and Karma
Unit testing in JavaScript with Jasmine and KarmaUnit testing in JavaScript with Jasmine and Karma
Unit testing in JavaScript with Jasmine and Karma
 
Angularjs - Unit testing introduction
Angularjs - Unit testing introductionAngularjs - Unit testing introduction
Angularjs - Unit testing introduction
 
Test like a pro with Ember.js
Test like a pro with Ember.jsTest like a pro with Ember.js
Test like a pro with Ember.js
 
JavaScript TDD with Jasmine and Karma
JavaScript TDD with Jasmine and KarmaJavaScript TDD with Jasmine and Karma
JavaScript TDD with Jasmine and Karma
 
Rapid prototyping and easy testing with ember cli mirage
Rapid prototyping and easy testing with ember cli mirageRapid prototyping and easy testing with ember cli mirage
Rapid prototyping and easy testing with ember cli mirage
 
Unit testing of java script and angularjs application using Karma Jasmine Fra...
Unit testing of java script and angularjs application using Karma Jasmine Fra...Unit testing of java script and angularjs application using Karma Jasmine Fra...
Unit testing of java script and angularjs application using Karma Jasmine Fra...
 
Reactive Streams and RxJava2
Reactive Streams and RxJava2Reactive Streams and RxJava2
Reactive Streams and RxJava2
 
Spring Boot
Spring BootSpring Boot
Spring Boot
 
Ember testing internals with ember cli
Ember testing internals with ember cliEmber testing internals with ember cli
Ember testing internals with ember cli
 
Quick tour to front end unit testing using jasmine
Quick tour to front end unit testing using jasmineQuick tour to front end unit testing using jasmine
Quick tour to front end unit testing using jasmine
 
#11.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_국비지원학원,재직자/실업자교육학원,스프링교육,마이바...
#11.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_국비지원학원,재직자/실업자교육학원,스프링교육,마이바...#11.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_국비지원학원,재직자/실업자교육학원,스프링교육,마이바...
#11.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_국비지원학원,재직자/실업자교육학원,스프링교육,마이바...
 
Practical Celery
Practical CeleryPractical Celery
Practical Celery
 
Unit testing JavaScript: Jasmine & karma intro
Unit testing JavaScript: Jasmine & karma introUnit testing JavaScript: Jasmine & karma intro
Unit testing JavaScript: Jasmine & karma intro
 
Django Celery - A distributed task queue
Django Celery - A distributed task queueDjango Celery - A distributed task queue
Django Celery - A distributed task queue
 
Testing Ember Apps: Managing Dependency
Testing Ember Apps: Managing DependencyTesting Ember Apps: Managing Dependency
Testing Ember Apps: Managing Dependency
 

Semelhante a Protractor framework architecture with example

Android UI Testing with Appium
Android UI Testing with AppiumAndroid UI Testing with Appium
Android UI Testing with AppiumLuke Maung
 
Web UI test automation instruments
Web UI test automation instrumentsWeb UI test automation instruments
Web UI test automation instrumentsArtem Nagornyi
 
Workshop 23: ReactJS, React & Redux testing
Workshop 23: ReactJS, React & Redux testingWorkshop 23: ReactJS, React & Redux testing
Workshop 23: ReactJS, React & Redux testingVisual Engineering
 
Test strategy for web development
Test strategy for web developmentTest strategy for web development
Test strategy for web developmentalice yang
 
Selenium-Browser-Based-Automated-Testing-for-Grails-Apps
Selenium-Browser-Based-Automated-Testing-for-Grails-AppsSelenium-Browser-Based-Automated-Testing-for-Grails-Apps
Selenium-Browser-Based-Automated-Testing-for-Grails-Appschrisb206 chrisb206
 
Mastering Test Automation: How To Use Selenium Successfully
Mastering Test Automation: How To Use Selenium SuccessfullyMastering Test Automation: How To Use Selenium Successfully
Mastering Test Automation: How To Use Selenium SuccessfullySpringPeople
 
ForwardJS 2017 - Fullstack end-to-end Test Automation with node.js
ForwardJS 2017 -  Fullstack end-to-end Test Automation with node.jsForwardJS 2017 -  Fullstack end-to-end Test Automation with node.js
ForwardJS 2017 - Fullstack end-to-end Test Automation with node.jsMek Srunyu Stittri
 
OSMC 2021 | inspectIT Ocelot: Dynamic OpenTelemetry Instrumentation at Runtime
OSMC 2021 | inspectIT Ocelot: Dynamic OpenTelemetry Instrumentation at RuntimeOSMC 2021 | inspectIT Ocelot: Dynamic OpenTelemetry Instrumentation at Runtime
OSMC 2021 | inspectIT Ocelot: Dynamic OpenTelemetry Instrumentation at RuntimeNETWAYS
 
AngularJS application architecture
AngularJS application architectureAngularJS application architecture
AngularJS application architectureGabriele Falace
 
Javascript ui for rest services
Javascript ui for rest servicesJavascript ui for rest services
Javascript ui for rest servicesIoan Eugen Stan
 
Toolbox for Selenium Tests in Java: WebDriverManager and Selenium-Jupiter
Toolbox for Selenium Tests in Java: WebDriverManager and Selenium-JupiterToolbox for Selenium Tests in Java: WebDriverManager and Selenium-Jupiter
Toolbox for Selenium Tests in Java: WebDriverManager and Selenium-JupiterBoni García
 
Javascript tdd byandreapaciolla
Javascript tdd byandreapaciollaJavascript tdd byandreapaciolla
Javascript tdd byandreapaciollaAndrea Paciolla
 
Protractor Testing Automation Tool Framework / Jasmine Reporters
Protractor Testing Automation Tool Framework / Jasmine ReportersProtractor Testing Automation Tool Framework / Jasmine Reporters
Protractor Testing Automation Tool Framework / Jasmine ReportersHaitham Refaat
 
OWASP ZAP Workshop for QA Testers
OWASP ZAP Workshop for QA TestersOWASP ZAP Workshop for QA Testers
OWASP ZAP Workshop for QA TestersJavan Rasokat
 
Using protractor to build automated ui tests
Using protractor to build automated ui testsUsing protractor to build automated ui tests
Using protractor to build automated ui tests🌱 Dale Spoonemore
 
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 applicationsLudmila Nesvitiy
 
Complete_QA_Automation_Guide__1696637878.pdf
Complete_QA_Automation_Guide__1696637878.pdfComplete_QA_Automation_Guide__1696637878.pdf
Complete_QA_Automation_Guide__1696637878.pdframya9288
 

Semelhante a Protractor framework architecture with example (20)

Android UI Testing with Appium
Android UI Testing with AppiumAndroid UI Testing with Appium
Android UI Testing with Appium
 
Web UI test automation instruments
Web UI test automation instrumentsWeb UI test automation instruments
Web UI test automation instruments
 
Workshop 23: ReactJS, React & Redux testing
Workshop 23: ReactJS, React & Redux testingWorkshop 23: ReactJS, React & Redux testing
Workshop 23: ReactJS, React & Redux testing
 
Test strategy for web development
Test strategy for web developmentTest strategy for web development
Test strategy for web development
 
Selenium-Browser-Based-Automated-Testing-for-Grails-Apps
Selenium-Browser-Based-Automated-Testing-for-Grails-AppsSelenium-Browser-Based-Automated-Testing-for-Grails-Apps
Selenium-Browser-Based-Automated-Testing-for-Grails-Apps
 
Mastering Test Automation: How To Use Selenium Successfully
Mastering Test Automation: How To Use Selenium SuccessfullyMastering Test Automation: How To Use Selenium Successfully
Mastering Test Automation: How To Use Selenium Successfully
 
Selenium.pptx
Selenium.pptxSelenium.pptx
Selenium.pptx
 
Beyond Unit Testing
Beyond Unit TestingBeyond Unit Testing
Beyond Unit Testing
 
ForwardJS 2017 - Fullstack end-to-end Test Automation with node.js
ForwardJS 2017 -  Fullstack end-to-end Test Automation with node.jsForwardJS 2017 -  Fullstack end-to-end Test Automation with node.js
ForwardJS 2017 - Fullstack end-to-end Test Automation with node.js
 
OSMC 2021 | inspectIT Ocelot: Dynamic OpenTelemetry Instrumentation at Runtime
OSMC 2021 | inspectIT Ocelot: Dynamic OpenTelemetry Instrumentation at RuntimeOSMC 2021 | inspectIT Ocelot: Dynamic OpenTelemetry Instrumentation at Runtime
OSMC 2021 | inspectIT Ocelot: Dynamic OpenTelemetry Instrumentation at Runtime
 
Protractor overview
Protractor overviewProtractor overview
Protractor overview
 
AngularJS application architecture
AngularJS application architectureAngularJS application architecture
AngularJS application architecture
 
Javascript ui for rest services
Javascript ui for rest servicesJavascript ui for rest services
Javascript ui for rest services
 
Toolbox for Selenium Tests in Java: WebDriverManager and Selenium-Jupiter
Toolbox for Selenium Tests in Java: WebDriverManager and Selenium-JupiterToolbox for Selenium Tests in Java: WebDriverManager and Selenium-Jupiter
Toolbox for Selenium Tests in Java: WebDriverManager and Selenium-Jupiter
 
Javascript tdd byandreapaciolla
Javascript tdd byandreapaciollaJavascript tdd byandreapaciolla
Javascript tdd byandreapaciolla
 
Protractor Testing Automation Tool Framework / Jasmine Reporters
Protractor Testing Automation Tool Framework / Jasmine ReportersProtractor Testing Automation Tool Framework / Jasmine Reporters
Protractor Testing Automation Tool Framework / Jasmine Reporters
 
OWASP ZAP Workshop for QA Testers
OWASP ZAP Workshop for QA TestersOWASP ZAP Workshop for QA Testers
OWASP ZAP Workshop for QA Testers
 
Using protractor to build automated ui tests
Using protractor to build automated ui testsUsing protractor to build automated ui tests
Using protractor to build automated ui tests
 
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
 
Complete_QA_Automation_Guide__1696637878.pdf
Complete_QA_Automation_Guide__1696637878.pdfComplete_QA_Automation_Guide__1696637878.pdf
Complete_QA_Automation_Guide__1696637878.pdf
 

Último

IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilV3cube
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsRoshan Dwivedi
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 

Último (20)

IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 

Protractor framework architecture with example

  • 2. Introduction  Protractor, formally known as E2E testing framework, is an open source functional automation framework designed specifically for AngularJS web applications. It was introduced during AngularJS 1.2 as a replacement of the existing E2E testing framework. The Protractor automation tool is also recommended by AngularJS for scenario testing.  For an angular app functional automation framework to automate the UI and functionality of the web application, we zeroed in on the Protractor automation tool.
  • 3. Features  Built on the top of WebdriverJS and Selenium server  Introduced new simple syntax to write tests  Allows running tests targeting remote addresses  Can take advantage of Selenium grid to run multiple browsers at once  Can use Jasmine or Mocha to write test suites
  • 4. Benefits  Protractor is a wrapper (built on the top) around Selenium WebDriver, so it contains every feature that is available in the Selenium WebDriver. Additionally, Protractor provides some new locator strategies and functions which are very helpful to automate the AngularJS application. Examples include things like: waitForAngular, By.binding, By.repeater, By.textarea, By.model, WebElement.all, WebElement.evaluate, etc.
  • 5. Installation Pre Requisite:  Download and install NodeJS. http://nodejs.org/download/. After installation make sure its path is configured correctly, so that command execution can find Node.
  • 6. Installation…  Open the command prompt and type in the following command to install protractor globally. - npm install –g protractor  Install Protractor Locally You can install protractor locally in your project directory. Go to your project directory and type in the following command in the command prompt: - npm install protractor  Verify Installation To verify your installation, please type in the command - Protractor –version  If Protractor is installed successfully then the system will display the installed version. Otherwise you will have to recheck the installation.  If you don’t have the Selenium server on your machine, then download the latest version onto your machine. If you want to run tests on different browsers, then please download the respective drivers as well. For example, Chrome driver will come in handy to run tests on the Chrome browser.
  • 7. Architecture of Framework Pages : Contains pages and elements(Locators) CommonUtils: Contains common methods or operations used for UI and API automation TestData : Contains constant value and payload in case of API automation Specs: Contains scenario - test cases Conf : Contains configuration and capabilities Reports : Allure reporting - screenshots and reports TestLogs : Contains logs
  • 8. Pages Example "use strict"; //Importing required files var data = require('../TestData/TestData.json'); var commonCode = require('../CommonUtils/CommonCode.js') var elementsPage = require('../CommonUtils/ElementsPage.js'); var log4js = require('log4js'); var logger = log4js.getLogger(); var XYZPage = function () { var EC = protractor.ExpectedConditions; // Login to the application this.loginInToTheApplication = async function (userNameElement,userName,passwordElement, password) { try { commonCode.wait_tillVisible(elementsPage.adminEmailTextbox); commonCode.sendDataToTextBox(userNameElement,userName); commonCode.sendDataToTextBox(passwordElement, password); commonCode.clickAction(elementsPage.loginButton); commonCode.wait_tillVisible(elementsPage.someTitle); expect(elementsPage.someTitle.isDisplayed()).toBe(true); } catch (e) { logger.error('Error while Logging in to the application' + e.message); } }; }; module.exports = new XYZPage(); It is used for UI automation.
  • 9. Common Code Example // To perform Click operation this.clickAction = async function (element) { try { this.wait_tillClickable(element); this.highlightElement(element); element.click(); } catch (e) { logger.error('Error while clicking on the web element' + e.message); } }; For UI
  • 10. Common Code Example // Get method with cookie this.getMethodWithCookie = async function (IP, PATH, COOKIE) { const expect = chai.expect; const chaiHttp1 = chai.request(IP); const response = await chaiHttp1.get(PATH).set(COOKIE); return response; }; For API
  • 11. Elements File Example "use strict"; var ElementsPage = function () { //landingPage this.xyz_button = element.all(by.css('input[value*="xyz"]')).get(0); this.emailTextbox = element(by.css('input[placeholder*="E-mail Address"]')); this.passwordTextbox = element(by.css('input[placeholder*="Password"]')); this.loginButton = element(by.css('button[class*="btn-login-btn"]')); }; module.exports = new ElementsPage();
  • 12. Test Data Example { "comments": " // Login Credentials", “url": "http://abc.net/", ”userName": abc, “password": "123", }
  • 13. Specs File Example "use strict"; //Importing required files var data = require('../TestData/TestData.json'); var commonCode = require('../CommonUtils/CommonCode.js') var elementsPage = require('../CommonUtils/ElementsPage.js'); var landingPage = require('../Pages/LandingPage.js'); //* Login scenario for XYZ automation describe("Login for XYZ - ", function () { beforeAll(function () { commonCode.appInitialization(data["url"]); }); it("Login to the portal", async function () { abcPage.loginInToTheApplication(elementsPage.emailTextbox,data["username"],elementsPage.passwordTextbox,data ["password"]); }); }); For UI
  • 14. Specs File Example "use strict"; // Importing necessary plugins and required files var chai = require('chai'), chaiHttp = require('chai-http'); chai.use(chaiHttp); var data = require('../TestData/TestData.json'); var commonCode = require('../CommonUtils/CommonCode.js') var elementsPage = require('../CommonUtils/ElementsPage.js'); // Sample API scenarios describe("Sample Api test cases - ", function () { beforeAll(function () { commonCode.appInitialization(data["adminURL"]); commonCode.getCookie(); browser.sleep(10000); }); // Get method with cookie sample it("GET method with cookie", async function () { const expect = chai.expect; await commonCode.getMethodWithCookie(IP, Path, global.cookie).then(function (response) { console.log(JSON.stringify(response)); console.log(response.status); console.log(JSON.stringify(response.body)); global.DataOne = response.body.dataOne; console.log('dataOne : ', response.body.dataOne); expect(response).to.have.status(data.successStatusCode); }); }); }); For API
  • 15. Conf File Example "use strict"; const log4js = require('log4js'); log4js.configure({ appenders: { everything: { type: 'file', filename: 'testLogs/Execution_Logs_Consolidated.log', maxLogSize: 10485760, backups: 3, compress: true } }, categories: { default: { appenders: ['everything'], level: 'debug' } } }); exports.config = { // Browser use capabilities: { 'browserName': 'chrome', //'chromeOptions': { //'args': ["no-sandbox", "--headless", "--disable-gpu", "--window-size=800x600"] //} }, // Framework selection framework: 'jasmine2', // Executing a single test case - "protractor Config.js" specs: ['./Specs/SampleSpecs.js'], // Executing suite - "protractor Config.js --suite spec1,spec2" suites: { spec1: [ 'Specs/FirstSpecs.js' ], spec2: [ 'Specs/SecondSpecs.js' ] },
  • 16. Conf File Example jasmineNodeOpts: { showColors: true, defaultTimeoutInterval: 400000, isVerbose: true, includeStackTrace: true }, onPrepare: function () { var AllureReporter = require('jasmine-allure-reporter'); jasmine.getEnv().addReporter(new AllureReporter({ allureReport: { resultsDir: 'allure-results' } })); jasmine.getEnv().afterEach(function (done) { browser.takeScreenshot().then(function (png) { allure.createAttachment('Screenshot', function () { return new Buffer(png, 'base64'); }, 'image/png')(); done(); }); }); } };
  • 17. Allure Reporting  For Windows, Allure is available from the Scoop commandline-installer.  To install Allure, download and install Scoop and then execute in the Powershell: - scoop install allure  Also Scoop is capable of updating Allure distribution installations. To do so navigate to the Scoop installation directory and execute  bincheckver.ps1 allure -u  This will check for newer versions of Allure, and update the manifest file. Then execute - scoop update allure
  • 18. Alternate commands….  Using Allure Command Line Tool  Add the allure-commandline dependency in your current project by running the below command. - npm install allure-commandline --save-dev
  • 19. Some Useful NPM commands  Installing node modules : npm install  Downgrade npm to specific version: npm install –g npm@2  Check npm version: npm –version  Install package locally: npm install package_name  Install package locally and make an entry in package.json as dependency : npm install package_name --save  List installed packages: npm ls  Update npm: npm update  Clean npm cache: npm cache clean –f ………….