I am testing the angular website. Our application starts with Login page and then vertical application selection frame (On the left corner of the page) which are Non-Angular web-pages and then after selecting the application in the left frame, it opens angular site inside the another frame (Right to the application selection frame).
I have the following code to automate the scenario using Cucumber and Protractor. After Logging in and launching the application from the left frame, I get the error message as:
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
Please find the code snippet 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();
});