Hi All,
I am try to use codecept for our automating UI test case.we are using BDD structure
Below is my requirement.
1.Frame work code should be separate
2.Test code should access framework code for writing and executing the test case
Below thing i did.
1.separate framework code and test code
2.Created 2 folder
Framework code
Project code
In frame work code i have below file.
1.Node modules
2.Package.json
3.Index.json(Its the entry point in package.json)
4.Utility folder(Framework code)
In Test code:
1.test case
Feature file and steps file
2.Codecept config
3.Codecept helper(Puppeteer)
If we are trying to access utility file below error is displaying
ReferenceError: actor is not defined
Utility Code:
module.exports = (function() {
I = actor();
return actor({
/**
-
“navigateTo” API will use to reach on particular screen
-
Input of this API is breadcrum navigation sequnce .
-
if you want to reach grandhchild then input(parent,child,grandchild )
-
origin is to launch the start screen which would execute for each screen .
*/
navigateTo : function(){
var arg=0;
console.log("arguments"+arguments.length,arguments[0],arguments[1]);
_navigateToScreen(screenTree["origin"]);
var screenObj = screenTree[arguments[arg]];
console.log("Object"+JSON.stringify(screenObj, null, 4))
do{
_navigateToScreen(screenObj);
if("screenWait" in screenObj)
{
_delayOnScreen(screenObj.screenWait);
}
if("screenValidationObj" in screenObj)
{
console.log("Validation Object"+JSON.stringify(screenObj.screenValidationObj, null, 4))
_validateScreen(screenObj.screenValidationObj);
}
else{
console.log("Warnning: You have not defined the Validation object");
}
arg++;
screenObj = screenObj[arguments[arg]];
}while(arg<arguments.length)
},
/**
-
@param {any} chnumber
-
Press the channel number digit by digit .
*/
zapToService: function(chnumber){
var serviceNo,i;
serviceNo = chnumber.toString();
for (i=0;i<serviceNo.length;i++)
{
I.pressKey(serviceNo[i]);
}
},
enterValidPin: function(){
var i =0;
within({id:"_dialogues_"}, () => {
for (i;i<CONSTANT.validPin.length;i++)
{
I.pressKey(CONSTANT.validPin[i])
}
})
},
enterInvalidPin: function (){
within({id:"_dialogues_"}, () => {
for (var i= 0 ;i<CONSTANT.invalidPin.length;i++)
{
I.pressKey(CONSTANT.invalidPin[i])
}
// I.seeTextEquals(CONSTANT.constStrings.invalidPinText,CONSTANT.XPATH.dialogInvaildText)
I.see(CONSTANT.constStrings.invalidPinText)
});
},
});
}());
Package.json:
{
"name": "nuts",
"version": "1.0.0",
"description": "",
"main": "buid/index.js",
"scripts": {
"build": "babel src -d build"
},
"anpm install uthor": "",
"devDependencies": {
"@babel/cli": "^7.8.4",
"@babel/core": "^7.8.6",
"@babel/node": "^7.8.4",
"@babel/preset-env": "^7.8.6",
"babel-cli": "^6.26.0",
"babel-core": "^6.26.3",
"babel-preset-es2015": "^6.24.1",
"codeceptjs": "^2.0.6",
"milsymbol": "^2.0.0",
"npm-run": "*",
"puppeteer": "^1.13.0",
"tesseractocr": "*",
"webdriverio": "^5.7.0",
"zip-local": "*"
},
"dependencies": {
"babel-install": "^2.1.0",
"esm": "^3.2.25",
"latest-version": "^4.0.0",
"nodemon": "^2.0.2",
"rimraf": "^3.0.2"
}
}