I am currently developing a set of tests using Protractor to test an AngularJS app that my company are developing. When I currently run through my tests, I am getting a failure on one of them, but can't figure out why... The error message says:
A Jasmine spec timed out. Resetting the WebDriver Control Flow.
The error message is shown at the end of the execution of the first of the following two test scripts, and the next thing to be shown in the console is the console.log()
statement from the start of the second test:
it('should navigate to the Charts page', function() {
console.log("Start Charts page test");
browser.waitForAngularEnabled(false);
browser.actions().mouseMove(chartsMenuBtn).perform();
chartsMenuBtn.click();
browser.waitForAngularEnabled(true);
browser.call(closeDlg);
expect(browser.getCurrentUrl()).toBe(VM + '/#/charts');
});
/*Test that 'Export' menu item works correctly */
it('should navigate to the Export page', function() {
console.log("Start Export page test");
browser.waitForAngularEnabled(true); //false);
browser.actions().mouseMove(exportMenuBtn).perform();
exportMenuBtn.click().then(function(){
console.log("End Export page test (then call)");
expect(browser.getCurrentUrl()).toBe(VM + '/#/export');
});
console.log("End Export page test");
});
Inside the first of these two test scripts, I am calling the function closeDlg()
using the line: browser.call(closeDlg);
- this function is defined in the same spec.js
file as where these tests are written with:
function closeDlg(){
browser.waitForAngularEnabled(false);
console.log("closeDlg() function called ")
var EC = protractor.ExpectedConditions;
var chartConfigForm = element(by.className('class="ui-tab-container ui-tab-vertical'));
var closeDlgBtn = element(by.buttonText('Cancel'));
browser.call(function(){
console.log("About to click closeDlgBtn ");
});
closeDlgBtn.click();
browser.call(function(){
console.log("just clicked closeDlgBtn ");
});
browser.call(function(){
console.log("End of closeDlg() function ");
});
}
and all of the console.log()
statements from this function are displayed in the console, indicating that all of the code inside this function executes as expected.
This appear to suggest that the timeout is occurring on the expect(browser.getCurrentUrl()).toBe(VM + '/#/charts');
line, but I can see in the browser where the test scripts are being run that this is the current URL at the time that this line is executed.
After the line
End of closeDlg() function
is printed to the console from the closeDlg()
function, that's when the timeout happens, which suggests that it's the line:
expect(browser.getCurrentUrl()).toBe(VM + '/#/charts');
that's causing the script to timeout, since that is the next line that will be executed.
I have tried setting browser.waitforAngularEnabled(true);
& browser.waitForAngularEnabled(false);
in various places within the test script, but nothing seems to have resolved or made a difference to the timeout error at all.
Does anyone have any suggestions why I'm getting this? How can I fix it?