Currently, I am conducting tests on an Angular website. Our application flow begins with a Login page followed by a vertical application selection frame (located in the left corner of the page) that consists of non-Angular web pages. Once the user selects an application from the left frame, the Angular site opens within another frame to the right of the application selection frame.
While attempting to automate this scenario using Cucumber and Protractor, I encountered the following error message after logging in and launching the application:
Uncaught exception: Error while waiting for Protractor to sync with the page: "angular could not be found on the window".
[launcher] Process exited with error code 1
Process finished with exit code 1
The relevant code snippet is provided below:
var chai = require('chai');
var chaiAsPromised = require('chai-as-promised');
chai.use(chaiAsPromised);
var expect = chai.expect;
var assert = chai.assert;
var myStepDefinitionsWrapper = function () {
this.Given(/^I login to the application with valid (.*) and (.*)$/, function (username, password) {
browser.driver.get(browser.baseUrl);
browser.driver.wait(function () {
return browser.driver.isElementPresent(by.id("ContentPlaceHolder1_UsernameTextBox"));
}, 10000);
browser.driver.findElement(by.id("ContentPlaceHolder1_UsernameTextBox")).then(function (usernameField) {
usernameField.sendKeys(username);
});
browser.driver.findElement(by.id("ContentPlaceHolder1_PasswordTextBox")).then(function (passwordField) {
passwordField.sendKeys(password);
});
return browser.driver.findElement(by.id("ContentPlaceHolder1_SubmitButton")).click();
});
this.Given(/^I launch the application from application selection page$/, function () {
browser.driver.wait(function () {
return browser.driver.isElementPresent(by.xpath("//a[starts-with(@class,'cp-icon') and contains(@style,'applaunch_default_26x26')]"));
}, 10000);
browser.driver.findElement(by.xpath("//a[starts-with(@class,'cp-icon') and contains(@style,'applaunch_default_26x26')]")).click();
browser.driver.wait(function () {
return browser.driver.isElementPresent(by.xpath("//span[contains(@title,'AppName')]"));
}, 10000);
return browser.driver.findElement(by.xpath("//span[contains(@title,'AppName')]")).click();
});
this.When(/^I open the task for the (.*)$/, function (PersonName) {
//Anugular Website starts from here
browser.waitForAngular();
return element(by.xpath("//td[contains(text(),'" + personName + "')]/following::td[2]/button[text()='Perform']")).click();
});