-
Notifications
You must be signed in to change notification settings - Fork 1
Tutorial Create a New Test
#Scenario to be Automated
- Open the AngularJS home page (https://angularjs.org)
- Navigate to "The Basics" section
- Enter "world" into the "Name:" text box where it says "Enter your name here"
- Verify that the text below the text box includes the text "world" (it actually should say "Hello world!")
##Step 1 - Preparation and dependencies
- GitHub for Windows - includes Git Bash and Git GUI
- Node.js platform
- Node package protractor - npm install protractor -g
- Java - needed for the selenium-standalone-server that protractor uses
- Node package keyword - npm install keyword
- Node package async - npm install async
- Node package dictionaryjs - npm install dictionaryjs
- Node package replace - npm install replace
- Node package jasmine-reporters - npm install jasmine-reporters@1.0.1
- Node package jasmine-spec-reporter - npm install jasmine-spec-reporter@1.1.0
##Step 2 - Create tests/AngularJSYourName.xlsx

##Step 3 - Generate scripts and specifications in tests/AngularJSYourName/ Generate the .pro.js and .script.js files (run utilities/GenerateScriptnProJS.hta)

##Step 4 - Update helpers/URLS.js Make sure that this line is in URLS.js:
dict.set('LIVE', 'https://angularjs.org/');
var Urls = (function () {
function Urls() {}
Urls.prototype.load = function (dict) {
dict.set('SYSTEST', 'https://angularjs.org/');
dict.set('LIVE', 'https://angularjs.org/');
dict.set('UAT', 'https://angularjs.org/');
dict.set('LOCAL', 'http://localhost');
dict.set('LOCALHOST', 'http://localhost');
};
return Urls;
})();
module.exports = Urls;##Step 5 - Add pages/AngularJSHomePage.js
var AngularJSHomePage = (function () {
function AngularJSHomePage() {
this.yourNameIn = element(by.model('yourName'));
this.yourNameOut = element(by.binding('yourName'));
}
AngularJSHomePage.prototype.setYourName = function (Name) {
this.yourNameIn.clear();
this.yourNameIn.sendKeys(Name);
};
AngularJSHomePage.prototype.getYourName = function () {
return this.yourNameOut.getText();
};
return AngularJSHomePage;
})();
module.exports = AngularJSHomePage;##Step 6 - Add keywords/AngularJS.keywords.js
var key = require('keyword'); // keyword functionality
try { key(require('./AngularJS.private.keywords')); } catch(err) { console.log(err) }
try { key(require('./Just.private.keywords')); } catch(err) { }
var AngularJSKeywords = {
"AngularJS.SetYourName":[
"Just.GetValueFromParams", ["$1","name"],"=> $name",
"AngularJSPrivate.SetYourName", ["$name"]
],
"AngularJS.GetYourName":[
"AngularJSPrivate.GetYourName", "=> $nameOut"
],
"AngularJS.CheckYourName":[
"Just.GetValueFromParams", ["$1","name"],"=> $nameIn",
"AngularJSPrivate.GetYourName", "=> $nameOut",
"AngularJSPrivate.CheckYourName", ["$nameIn", "$nameOut"], "=> $nameOut"
]
};
module.exports = AngularJSKeywords;##Step 7 - Add keywords/Training.private.keywords.js
var AngularJSHomePage = require("../pages/AngularJSHomePage");
var AngularJSPrivateKeywords = {
"AngularJSPrivate.SetYourName": function(next, name) {
var angularJSHomePage = new AngularJSHomePage();
angularJSHomePage.setYourName(name);
next();
},
"AngularJSPrivate.GetYourName": function(next) {
var angularJSHomePage = new AngularJSHomePage();
angularJSHomePage.getYourName().then(function (NameOut) {
next(NameOut);
});
},
"AngularJSPrivate.CheckYourName": function(next, nameIn, nameOut) {
console.log("AngularJS.CheckYourName: " + nameOut + " contains " + nameIn);
var angularJSHomePage = new AngularJSHomePage();
expect(nameOut).toContain(nameIn);
next();
}
};
module.exports = AngularJSPrivateKeywords;##Step 8 - Run webdriver
Start a Bash command session by clicking on the Git Bash icon on the desktop
or on the Git Bash entry in the start menu to start a Git Bash command window session. Then enter webdriver-manager start at the $ prompt to start Selenium webdriver. (The very first time you do this you should run webdriver-manager update beforehand).
##Step 9 - Run the test Open another Git Bash session and change directory to the parent of the tests folder (../tests/) and run the following command.
protractor protractorConfig.js --params.testEnv=live --capabilities.browserName="chrome" --specs="tests\AngularJSYourName\*.pro.js"Check the test run results (defaults to /temp/AutomatedTestResults/ but this can be changed in protractorConfig)
##Step 10 - Try this for parallel execution
protractor protractorConfig.js --params.testEnv=live --capabilities.browserName="chrome" --capabilities.shardTestFiles=true --capabilities.maxInstances=99 --specs="tests\AngularJSYourName\*.pro.js"Pasilla
Links: Home, [General Concepts](General Concepts), Tutorial - Create a New Test, Data Parameters