Skip to content

Protractor + Cucumber + Page Object Model - Test steps shows passed without execution #1478

Closed
@gitautomateudemy

Description

@gitautomateudemy
  • Node.js Version: 8.8.0
  • OS: Windows 7
  • ** protractor: 5.3.0
    *** Cucumber : 4.2.0
    *** Protractor cucumber framework : 4.2.0

// My page file:
createIncpage = function (){

this.selIncidentView = function(){
     browser.ignoreSynchronization = true;
	incidentSection.click().then(function(){
		return openInc.click();
		}).then(function(){
		return browser.switchTo().frame(0);
	});
};

this.selIncident = function(){
		browser.ignoreSynchronization = true;
		commnFunctions.waitForElement(incElement).then(function(){
		return incidentSelcted.click();
	});
};

module.exports = new createIncpage ();

Step file like below:

var chai = require('chai');
var expect = chai.expect;
var createIncpage = require ('../pages/createIncidentPage.js');
var {Before, After, Given, When, Then} = require ('cucumber');

// Style:1 : without callback
Given('user in incident view' , function (){
return createIncpage.selIncidentView();
});

//Style 2: with callback
Given('user in incident view' , function (callback){
return createIncpage.selIncidentView(function callback(){
callback();
});
});

//Style #3 : using await
Given('user in incident view' , function (){
await createIncpage.selIncidentView();

});

Both the ways are not working, the style#1, gives test results without execution and style#2 doesnot go to the next step.
Style#3 gives me error unexpected token at createIncpage.selIncidentView();

Can somebody please help what am i doing wrong. how do i achieve synchronization

Also, if i remove the page file & write everything in step file it works fine.
like below:

//Step file without page object:

Given('user in incident view' , function (callback){
browser.ignoreSynchronization = true;
incidentSection.click().then(function(){
return openInc.click();
}).then(function(){
browser.switchTo().frame(0);
return callback();
});
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions