KEMBAR78
Angular js automation using protractor | PPTX
AngularJS Automation using
Protractor
Who Am I?
• Ravi Kumar Gupta
• SSE@Accion Labs India
What is Protractor
● An AngularJS E2E Testing Framework
● A new replacement of the existing E2E Testing
framework Angular Scenario
• Everying in Protractor is a Promise and this is
very important.
What’s Different
• Built on WebdriverJS and Selenium Server
• New syntax when writing tests
• Allows running tests targeting remote
addresses, No longer need to have test files on
the server being tested
• Can take advantage of Selenium Grid to run
multiple browsers at once; ie Sauce Labs
• Has it’s own runner, no need for Karma
• Can use Jasmine or Mocha to write test suites
Global Variable
• browser: browser.get()
• element and by:
element(by.model('yourName'))
• protractor: protractor.Key
WebDriverjs
• WebDriver referes to the language bindings
and the implementation of browser control
WebDriverJs has an important difference from
other language – it is asyschronous
WebDriver
VS
WebDriverJS
Java
driver.get(url);
driver.element(El);
Javascript
driver.get(url).then( function() {
driver.click(El);
})
Avoid doing this
Control Flow
• No Sleep
• No Wait
• No Promises
The Configuration File
There are five things you need to
provide so Protractor can run your
specs:
1.Selenium Server Configuration
2.Where your spec files are located
3.Browser capabilities required by spec files
4.The Base Url for your spec files
5.Jasmine/Mocha Configuration
Selenium Configuration
There are three ways to specify what Selenium
Server to use:
1. seleniumServerJar and seleniumPort - to start
Selenium Standalone locally.
2. seleniumAddress - to connect to a Selenium server
which is already running.
3. sauceUser/sauceKey - to use remote Selenium servers
via SauceLabs.
Debugging
• browser.pause()
• browser.debugger()
• Element-explorer
.bin/elementexplorer http://localhost:8080
Or
protractor –elementExplorer
Note: Use $interval service instead of $timeout
Reports
• Console output
• Screenshot
• HTML Reporter
Demo
Any
?
References
• http://www.protractortest.org
• https://mochajs.org/
• https://www.npmjs.com/package/astrolabe
• http://chaijs.com/
• https://www.npmjs.com/package/chai-as-
promised
• https://www.npmjs.com/package/mocha-
spectreport-reporter

Angular js automation using protractor