I am having trouble trying to use lib protractor-intercept which I think is probably a Javascript async issue that I am having. This code works but it wont print out the console.log line. Any idea on how I might have got this wrong?
When('the {string} button is clicked', async (buttonName: string) => {
var intercept = new Intercept(browser);
intercept.addListener();
await page.submitApplication(buttonName);
intercept.getRequests().then(function(reqs) {
console.log("Intercepted!! " + reqs);
//TODO extract a value from submit http query response
});
await page.waitForSpinnerButtonFinish();
});
And here is my page object method:
submitApplication(buttonName: string) {
return new Promise(function (resolve) {
var promised = element(by.css('app form')).element(
by.cssContainingText('button span', buttonName)).click();
return resolve(promised);
});
}