Reputation: 48
I am trying to run a simple test but the test is failing because of the Protractor is trying to sync with the page but cannot because it is not in Angular. Any ideas what needs to be changed?
Config File :
exports.config = {
allScriptsTimeout: 11000,
specs : [
'./src/**/*.e2e-spec.ts',
'/pages/**/*.Tracker_pageobject.ts',
],
capabilities : {
'browserName': 'chrome'
},
directConnect : true,
baseUrl : 'http://localhost:4200/',
useAllAngular2AppRoots: true,
framework : 'jasmine',
spec file:
describe('Test Application', () => {
beforeEach(() => {
browser.waitForAngularEnabled(false);
browser.driver.get(environment.url + "/login");
browser.driver.manage().window().maximize();
browser.waitForAngularEnabled(true);
});
it('should not open login page when user enters invalid Username & Password', () => {
var loginpage = new dashboard();
browser.sleep(2000);
loginpage.userName('abc');
browser.sleep(2000);
loginpage.password('cde');
loginpage.loginbtn();
element(by.className('mat-error ng-tns-c33-4 ng-star-inserted')).getText().then(function(value){
browser.waitForAngular();
browser.sleep(5000);
console.log(value);
});
browser.sleep(5000);
});
it('should not open login page when user enters spaces', () => {
browser.sleep(5000);
var loginpage = new dashboard();
loginpage.userName(' ');
browser.sleep(2000);
loginpage.password(' ');
loginpage.loginbtn();
element(by.className('mat-error ng-tns-c33-4 ng-star-inserted')).getText().then(function(value){
browser.waitForAngular();
browser.sleep(5000);
console.log(value);
});
browser.sleep(5000);
});
loginpage(POM).ts
import { browser, by, element } from 'protractor';
var loginpage = function(){
var userNamefield = element(by.css("input[formcontrolname = 'email']"));
var passwordfield = element(by.css("input[formcontrolname = 'password']"));
var loginbutton = element(by.xpath('//*[@id="login-form"]/form/button'));
var logoutbtn = element(by.xpath('//*[@id="main-navigation"]/fuse-nav-vertical-group/div[1]/ul/li[3]/a'));
this.userName = function(vusername){
userNamefield.sendKeys(vusername);
};
this.password = function(vpassWord){
passwordfield.sendKeys(vpassWord);
};
this.loginbtn = function(btn){
loginbutton.click();
};
Getting the below message: Failed: Error while waiting for Protractor to sync with the page: "both angularJS testability and angular testability are undefined. This could be either because this is a non-angular page or because your test involves client-side navigation, which can interfere with Protractor's bootstrapping. See http://git.io/v4gXM for details
Any help will be appreciated
Upvotes: 0
Views: 489
Reputation: 1643
remove all lines with browser.waitForAngularEnabled(....);
from BeforeEach()
block in specs. And add browser.waitForAngularEnabled(false);
to onPrepare()
section in the protractor.conf
file
Upvotes: 1
Reputation: 1643
Change this block:
beforeEach(() => {
browser.waitForAngularEnabled(false);
browser.driver.get(environment.url + "/login");
browser.driver.manage().window().maximize();
browser.waitForAngularEnabled(true);
});
to this one:
beforeEach(() => {
browser.waitForAngularEnabled(false);
browser.driver.get(environment.url + "/login");
browser.driver.manage().window().maximize();
});
You don't need wait for Angular.
Also you probably need take a look at Explicit waiters
in Selenium.
Upvotes: 0