SlideShare une entreprise Scribd logo
1  sur  34
Protractor Testing
Automation Tool Framework
Presented by Haitham Mahmoud
A Powerful JavaScript Framework
Introduction
Protractor plays an important role in the Testing of
AngularJS applications and works as a Solution
integrator combining powerful technologies like
Selenium
It is intended not only to test AngularJS application but
also for writing automated regression tests for normal
Web Applications as well.
What is AngularJS
AngularJS is a JavaScript-based open-source front-end
web application framework mainly maintained by
Google and by a community of individuals and
corporations to address many of the challenges
encountered in developing single-page applications.
Why Do We Need Protractor Framework?
JavaScript is used in almost all web applications. As the
applications grow, JavaScript also increases in size and
complexity. In such case, it becomes a difficult task for
Testers to test the web application for various scenarios.
Sometimes it is difficult to capture the web elements in
AngularJS applications using JUnit or Selenium WebDriver.
AngularJS application
AngularJS applications are Web Applications which uses
extended HTML's syntax to express web application
components. It is mainly used for dynamic web applications.
These applications use less and flexible code compared with
normal Web Applications.
Angular JS web elements using Normal
Selenium Web driver
Selenium is not able to identify those web elements using
Selenium code. So, Protractor on the top of Selenium can
handle and controls those attributes in Web Applications.
The protractor is an end to end testing framework
for Angular JS based applications. While most frameworks
focus on conducting unit tests for Angular JS applications,
Protractor focuses on testing the actual functionality of an
application.
Before we start Protractor
We need to install the following:
1. Selenium webdriver
2. NPM (Node.js)
How to install Node.js on Windows
2. NPM (Node.js)
1. NodeJS Installation, we need to install NodeJS to install Protractor.
1. Go to the site https://nodejs.org/en/download/ and download installer.
How to install Node.js on Windows
2. NPM (Node Package Manager) - (Node.js)
1. NodeJS Installation, we need to install NodeJS to install Protractor.
2. Double click on the downloaded .msi file to start the installation.
Click the Run button in the first screen
to begin the installation.
How to install Node.js on Windows
2. NPM (Node Package Manager) - (Node.js)
1. NodeJS Installation, we need to install NodeJS to install Protractor.
2. Double click on the downloaded .msi file to start the installation.
Click the Run button in the first screen
to begin the installation.
Running your first Hello world application
in Node.js
1. Create file Node.js with file name firstprogram.js
var http = require('http');
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/html'});
res.end('Hello World!');
}).listen(8080);
Executing the code
2. Save the file on your computer: C:UsersYour Name firstprogram.js
Output
3. Start your internet browser, and type in the address:
http://localhost:8080
Protractor Installation
1. Open command prompt and type "npm install –g protractor" and hit
Enter. Then type “Protractor --version”
Protractor Installation
2. Update the Web driver manager >> The CMD was opening
Now type “webdriver-manager update”
The web driver manager is used for running the tests against the angular
web application in a specific browser. After Protractor is installed, the web
driver manager needs to be updated to the latest version. This can be
done by running the following command in the command prompt.
Protractor Installation
2. Update the Web driver manager
Protractor Installation
3. Start the web driver manager >> The CMD was opening
Now type “webdriver-manager start”
This step will run the web driver manager in the background and will listen
to any tests which run via protractor.
Protractor Installation
4. Now, if you go to the following URL
(http://localhost:4444/wd/hub/static/resource/hub.html)
in your browser, you will actually see the Web driver manager running
in the background.
Let’s Go to test
Sample AngularJS application testing using
Protractor
Protractor needs two files to run, a spec file and configuration file.
1. Configuration file: This File helps protractor to where the test files
are placed (specs.js) and to talk with Selenium server (Selenium
Address). Chrome is the default browser for Protractor.
2. Spec file: This File contains the logic and locators to interact with
the application.
Let’s Go to test
Sample AngularJS application testing using
Protractor
1. We have to login https://angularjs.org
2. Enter the text as “Haitham“
3. Now we have to capture the text from the webpage after entering
the name and need to verify with the expected text.
Let’s Go to test
Sample AngularJS application testing using
Protractor
We have to prepare configuration file (conf.js) and spec file (spec.js) as
mentioned above.
Now we will create (spec.js)
describe('Enter Haitham Name', function() {
it('should add a Name as Haitham', function() {
browser.get('https://angularjs.org');
element(by.model('yourName')).sendKeys('Haitham');
var myName= element(by.xpath("//input[@class='ng-valid ng-dirty ng-valid-parse ng-touched ng-empty"]'));
expect(myName.getText()).toEqual('Hello Haitham!');
});
});
Let’s Go to test
Sample AngularJS application testing using
Protractor
We have to prepare configuration file (conf.js) and spec file (spec.js) as
mentioned above.
Now we will create (conf.js)
exports.config = {
seleniumAddress: 'http://localhost:4444/wd/hub',
specs: ['spec.js']
};
Let’s Go to test
Sample AngularJS application testing using
Protractor
• Execution of the Code
1. Open the command prompt.
2. Make sure selenium web driver manager is up and running. For that
give the command as "webdriver-manager start" and hit Enter.
3. Open a new command prompt and give the command as "protractor
conf.js" to run the configuration file.
Let’s Go to test
Sample AngularJS application testing using
Protractor
Let’s Go to test
Sample AngularJS application testing using
Protractor
Generate Reports using Jasmine
Reporters
Protractor supports Jasmine reporters to generate test reports. In this
section, we will use JunitXMLReporter to generate Test execution
reports automatically in XML format.
Installation of Jasmine Reporter
There are two way you can do this, locally or globally
1. Open command prompt execute the following command to install
locally
Above command will install jasmine reports node-modules locally
means from the directory where we are running the command in
command prompt.
npm install --save-dev jasmine-reporters@^2.0.0
Installation of Jasmine Reporter
Ignore this command
There are two way you can do this, locally or globally
2. Open command prompt execute the following command for global
installation
Above command will install jasmine reports node-modules locally
means from the directory where we are running the command in
command prompt.
npm install –g jasmine-reporters@^2.0.0
Install the jasmine reporters locally
1. Execute the command.
npm install --save-dev jasmine-reporters@^2.0.0
Installation of Jasmine Reporter
There are two way you can do this, locally or globally
1. Open command prompt execute the following command to install
locally
Install the jasmine reporters locally
2. Check the installation folders in the directory.
" Node_modules" should be available if it is successfully installed like in
below snapshot.
Install the jasmine reporters locally
3. Add the following colored code to an existed conf.js file
exports.config = {
seleniumAddress: 'http://localhost:4444/wd/hub',
capabilities: {
'browserName': 'firefox'
},
specs: ['spec.js'],
framework: 'jasmine2' ,
onPrepare: function() {
var jasmineReporters = require('C:/Users/RE041943/Desktop/guru/node_modules/jasmine-
reporters');
jasmine.getEnv().addReporter(new jasmineReporters.JUnitXmlReporter(null, true, true)
);
}
};
Install the jasmine reporters locally
4. In code, we are generating the report "JUnitXmlReporter" and giving
the Path where to store the report.

Contenu connexe

Tendances

Tendances (20)

Angular data binding
Angular data binding Angular data binding
Angular data binding
 
Webdriver.io
Webdriver.io Webdriver.io
Webdriver.io
 
Selenium WebDriver
Selenium WebDriverSelenium WebDriver
Selenium WebDriver
 
Angular 2.0 forms
Angular 2.0 formsAngular 2.0 forms
Angular 2.0 forms
 
Express JS Middleware Tutorial
Express JS Middleware TutorialExpress JS Middleware Tutorial
Express JS Middleware Tutorial
 
Angular 14.pptx
Angular 14.pptxAngular 14.pptx
Angular 14.pptx
 
Arquitetura Node com NestJS
Arquitetura Node com NestJSArquitetura Node com NestJS
Arquitetura Node com NestJS
 
FRONT-END WEB DEVELOPMENT WITH REACTJS
FRONT-END WEB DEVELOPMENT WITH REACTJSFRONT-END WEB DEVELOPMENT WITH REACTJS
FRONT-END WEB DEVELOPMENT WITH REACTJS
 
Technical Tips: Visual Regression Testing and Environment Comparison with Bac...
Technical Tips: Visual Regression Testing and Environment Comparison with Bac...Technical Tips: Visual Regression Testing and Environment Comparison with Bac...
Technical Tips: Visual Regression Testing and Environment Comparison with Bac...
 
Selenium WebDriver
Selenium WebDriverSelenium WebDriver
Selenium WebDriver
 
Webdriver io presentation
Webdriver io presentationWebdriver io presentation
Webdriver io presentation
 
Selenium WebDriver training
Selenium WebDriver trainingSelenium WebDriver training
Selenium WebDriver training
 
Angularjs PPT
Angularjs PPTAngularjs PPT
Angularjs PPT
 
Routing & Navigating Pages in Angular 2
Routing & Navigating Pages in Angular 2Routing & Navigating Pages in Angular 2
Routing & Navigating Pages in Angular 2
 
Spring AOP in Nutshell
Spring AOP in Nutshell Spring AOP in Nutshell
Spring AOP in Nutshell
 
Spring Framework
Spring FrameworkSpring Framework
Spring Framework
 
Spring Security
Spring SecuritySpring Security
Spring Security
 
Angular Directives | Angular 2 Custom Directives | Angular Tutorial | Angular...
Angular Directives | Angular 2 Custom Directives | Angular Tutorial | Angular...Angular Directives | Angular 2 Custom Directives | Angular Tutorial | Angular...
Angular Directives | Angular 2 Custom Directives | Angular Tutorial | Angular...
 
Introduction to Swagger
Introduction to SwaggerIntroduction to Swagger
Introduction to Swagger
 
Document your rest api using swagger - Devoxx 2015
Document your rest api using swagger - Devoxx 2015Document your rest api using swagger - Devoxx 2015
Document your rest api using swagger - Devoxx 2015
 

Similaire à Protractor Testing Automation Tool Framework / Jasmine Reporters

Presentation_Protractor
Presentation_ProtractorPresentation_Protractor
Presentation_Protractor
Umesh Randhe
 
Steps to write Selenium
Steps to write Selenium  Steps to write Selenium
Steps to write Selenium
Rohit Thakur
 
Selenium Automation Using Ruby
Selenium Automation Using RubySelenium Automation Using Ruby
Selenium Automation Using Ruby
Kumari Warsha Goel
 

Similaire à Protractor Testing Automation Tool Framework / Jasmine Reporters (20)

AngularJS Project Setup step-by- step guide - RapidValue Solutions
AngularJS Project Setup step-by- step guide - RapidValue SolutionsAngularJS Project Setup step-by- step guide - RapidValue Solutions
AngularJS Project Setup step-by- step guide - RapidValue Solutions
 
Presentation_Protractor
Presentation_ProtractorPresentation_Protractor
Presentation_Protractor
 
Selenium for Tester.pdf
Selenium for Tester.pdfSelenium for Tester.pdf
Selenium for Tester.pdf
 
Front end workflow with yeoman
Front end workflow with yeomanFront end workflow with yeoman
Front end workflow with yeoman
 
Django simplified : by weever mbakaya
Django simplified : by weever mbakayaDjango simplified : by weever mbakaya
Django simplified : by weever mbakaya
 
Android UI Testing with Appium
Android UI Testing with AppiumAndroid UI Testing with Appium
Android UI Testing with Appium
 
An Overview of Angular 4
An Overview of Angular 4 An Overview of Angular 4
An Overview of Angular 4
 
Getting started with appium
Getting started with appiumGetting started with appium
Getting started with appium
 
Testing Java Web Apps With Selenium
Testing Java Web Apps With SeleniumTesting Java Web Apps With Selenium
Testing Java Web Apps With Selenium
 
Selenium.pptx
Selenium.pptxSelenium.pptx
Selenium.pptx
 
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
 
Selenium
SeleniumSelenium
Selenium
 
Protractor framework architecture with example
Protractor framework architecture with exampleProtractor framework architecture with example
Protractor framework architecture with example
 
Node JS - A brief overview on building real-time web applications
Node JS - A brief overview on building real-time web applicationsNode JS - A brief overview on building real-time web applications
Node JS - A brief overview on building real-time web applications
 
Exploring Maven SVN GIT
Exploring Maven SVN GITExploring Maven SVN GIT
Exploring Maven SVN GIT
 
Using galen framework for automated cross browser layout testing
Using galen framework for automated cross browser layout testingUsing galen framework for automated cross browser layout testing
Using galen framework for automated cross browser layout testing
 
Qa process
Qa processQa process
Qa process
 
Steps to write Selenium
Steps to write Selenium  Steps to write Selenium
Steps to write Selenium
 
Qa process
Qa processQa process
Qa process
 
Selenium Automation Using Ruby
Selenium Automation Using RubySelenium Automation Using Ruby
Selenium Automation Using Ruby
 

Dernier

CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
Health
 
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female serviceCALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
anilsa9823
 

Dernier (20)

Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS LiveVip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female serviceCALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
 

Protractor Testing Automation Tool Framework / Jasmine Reporters

  • 1. Protractor Testing Automation Tool Framework Presented by Haitham Mahmoud
  • 3. Introduction Protractor plays an important role in the Testing of AngularJS applications and works as a Solution integrator combining powerful technologies like Selenium It is intended not only to test AngularJS application but also for writing automated regression tests for normal Web Applications as well.
  • 4. What is AngularJS AngularJS is a JavaScript-based open-source front-end web application framework mainly maintained by Google and by a community of individuals and corporations to address many of the challenges encountered in developing single-page applications.
  • 5. Why Do We Need Protractor Framework? JavaScript is used in almost all web applications. As the applications grow, JavaScript also increases in size and complexity. In such case, it becomes a difficult task for Testers to test the web application for various scenarios. Sometimes it is difficult to capture the web elements in AngularJS applications using JUnit or Selenium WebDriver.
  • 6. AngularJS application AngularJS applications are Web Applications which uses extended HTML's syntax to express web application components. It is mainly used for dynamic web applications. These applications use less and flexible code compared with normal Web Applications.
  • 7. Angular JS web elements using Normal Selenium Web driver Selenium is not able to identify those web elements using Selenium code. So, Protractor on the top of Selenium can handle and controls those attributes in Web Applications. The protractor is an end to end testing framework for Angular JS based applications. While most frameworks focus on conducting unit tests for Angular JS applications, Protractor focuses on testing the actual functionality of an application.
  • 8. Before we start Protractor We need to install the following: 1. Selenium webdriver 2. NPM (Node.js)
  • 9. How to install Node.js on Windows 2. NPM (Node.js) 1. NodeJS Installation, we need to install NodeJS to install Protractor. 1. Go to the site https://nodejs.org/en/download/ and download installer.
  • 10. How to install Node.js on Windows 2. NPM (Node Package Manager) - (Node.js) 1. NodeJS Installation, we need to install NodeJS to install Protractor. 2. Double click on the downloaded .msi file to start the installation. Click the Run button in the first screen to begin the installation.
  • 11. How to install Node.js on Windows 2. NPM (Node Package Manager) - (Node.js) 1. NodeJS Installation, we need to install NodeJS to install Protractor. 2. Double click on the downloaded .msi file to start the installation. Click the Run button in the first screen to begin the installation.
  • 12. Running your first Hello world application in Node.js 1. Create file Node.js with file name firstprogram.js var http = require('http'); http.createServer(function (req, res) { res.writeHead(200, {'Content-Type': 'text/html'}); res.end('Hello World!'); }).listen(8080);
  • 13. Executing the code 2. Save the file on your computer: C:UsersYour Name firstprogram.js
  • 14. Output 3. Start your internet browser, and type in the address: http://localhost:8080
  • 15. Protractor Installation 1. Open command prompt and type "npm install –g protractor" and hit Enter. Then type “Protractor --version”
  • 16. Protractor Installation 2. Update the Web driver manager >> The CMD was opening Now type “webdriver-manager update” The web driver manager is used for running the tests against the angular web application in a specific browser. After Protractor is installed, the web driver manager needs to be updated to the latest version. This can be done by running the following command in the command prompt.
  • 17. Protractor Installation 2. Update the Web driver manager
  • 18. Protractor Installation 3. Start the web driver manager >> The CMD was opening Now type “webdriver-manager start” This step will run the web driver manager in the background and will listen to any tests which run via protractor.
  • 19. Protractor Installation 4. Now, if you go to the following URL (http://localhost:4444/wd/hub/static/resource/hub.html) in your browser, you will actually see the Web driver manager running in the background.
  • 20. Let’s Go to test Sample AngularJS application testing using Protractor Protractor needs two files to run, a spec file and configuration file. 1. Configuration file: This File helps protractor to where the test files are placed (specs.js) and to talk with Selenium server (Selenium Address). Chrome is the default browser for Protractor. 2. Spec file: This File contains the logic and locators to interact with the application.
  • 21. Let’s Go to test Sample AngularJS application testing using Protractor 1. We have to login https://angularjs.org 2. Enter the text as “Haitham“ 3. Now we have to capture the text from the webpage after entering the name and need to verify with the expected text.
  • 22. Let’s Go to test Sample AngularJS application testing using Protractor We have to prepare configuration file (conf.js) and spec file (spec.js) as mentioned above. Now we will create (spec.js) describe('Enter Haitham Name', function() { it('should add a Name as Haitham', function() { browser.get('https://angularjs.org'); element(by.model('yourName')).sendKeys('Haitham'); var myName= element(by.xpath("//input[@class='ng-valid ng-dirty ng-valid-parse ng-touched ng-empty"]')); expect(myName.getText()).toEqual('Hello Haitham!'); }); });
  • 23. Let’s Go to test Sample AngularJS application testing using Protractor We have to prepare configuration file (conf.js) and spec file (spec.js) as mentioned above. Now we will create (conf.js) exports.config = { seleniumAddress: 'http://localhost:4444/wd/hub', specs: ['spec.js'] };
  • 24. Let’s Go to test Sample AngularJS application testing using Protractor • Execution of the Code 1. Open the command prompt. 2. Make sure selenium web driver manager is up and running. For that give the command as "webdriver-manager start" and hit Enter. 3. Open a new command prompt and give the command as "protractor conf.js" to run the configuration file.
  • 25. Let’s Go to test Sample AngularJS application testing using Protractor
  • 26. Let’s Go to test Sample AngularJS application testing using Protractor
  • 27. Generate Reports using Jasmine Reporters Protractor supports Jasmine reporters to generate test reports. In this section, we will use JunitXMLReporter to generate Test execution reports automatically in XML format.
  • 28. Installation of Jasmine Reporter There are two way you can do this, locally or globally 1. Open command prompt execute the following command to install locally Above command will install jasmine reports node-modules locally means from the directory where we are running the command in command prompt. npm install --save-dev jasmine-reporters@^2.0.0
  • 29. Installation of Jasmine Reporter Ignore this command There are two way you can do this, locally or globally 2. Open command prompt execute the following command for global installation Above command will install jasmine reports node-modules locally means from the directory where we are running the command in command prompt. npm install –g jasmine-reporters@^2.0.0
  • 30. Install the jasmine reporters locally 1. Execute the command. npm install --save-dev jasmine-reporters@^2.0.0
  • 31. Installation of Jasmine Reporter There are two way you can do this, locally or globally 1. Open command prompt execute the following command to install locally
  • 32. Install the jasmine reporters locally 2. Check the installation folders in the directory. " Node_modules" should be available if it is successfully installed like in below snapshot.
  • 33. Install the jasmine reporters locally 3. Add the following colored code to an existed conf.js file exports.config = { seleniumAddress: 'http://localhost:4444/wd/hub', capabilities: { 'browserName': 'firefox' }, specs: ['spec.js'], framework: 'jasmine2' , onPrepare: function() { var jasmineReporters = require('C:/Users/RE041943/Desktop/guru/node_modules/jasmine- reporters'); jasmine.getEnv().addReporter(new jasmineReporters.JUnitXmlReporter(null, true, true) ); } };
  • 34. Install the jasmine reporters locally 4. In code, we are generating the report "JUnitXmlReporter" and giving the Path where to store the report.

Notes de l'éditeur

  1. Code Explanation: The basic functionality of the "require" function is that it reads a JavaScript file, executes the file, and then proceeds to return an object. Using this object, one can then use the various functionalities available in the module called by the require function. So in our case, since we want to use the functionality of http and we are using the require(http) command. In this 2nd line of code, we are creating a server application which is based on a simple function. This function is called, whenever a request is made to our server application. When a request is received, we are asking our function to return a "Hello World" response to the client. The writeHead function is used to send header data to the client and while the end function will close the connection to the client. We are then using the server.listen function to make our server application listen to client requests on port no 7000. You can specify any available port over here.
  2. describe('Enter Haitham Name', function()The describe syntax is from the Jasmine framework. Here "describe" ('Enter Haitham Name') typically defines components of an application, which can be a class or function etc. In the code suite called as "Enter Haitham ," it's just a string and not a code. it('should add a Name as Haitham ', function() browser.get('https://angularjs.org')As like in Selenium Webdriver browser.get will open a new browser instance with mentioned URL. element(by.model('yourName')).sendKeys(Haitham ')Here we are finding the web element using the Model name as "yourName," which is the value of "ng-model" on the web page. var myName = element(by.xpath(('//input[@class=“ng-valid ng-dirty ng-valid-parse ng-touched ng-empty”]'))Here we are finding the web element using XPath and store its value in a variable “myName". expect(guru.getText()).toEqual('Hello Haitham!')Finally we are verifying the text which we have got from the webpage (using gettext() ) with expected text .
  3. seleniumAddress: 'http://localhost:4444/wd/hub'The Configuration file tells Protractor the location of Selenium Address to talk with Selenium WebDriver. specs: ['spec.js']This line tells Protractor the location of test files spec.js
  4. seleniumAddress: 'http://localhost:4444/wd/hub'The Configuration file tells Protractor the location of Selenium Address to talk with Selenium WebDriver. specs: ['spec.js']This line tells Protractor the location of test files spec.js
  5. seleniumAddress: 'http://localhost:4444/wd/hub'The Configuration file tells Protractor the location of Selenium Address to talk with Selenium WebDriver. specs: ['spec.js']This line tells Protractor the location of test files spec.js