Angular error not defined "while running Protractor test in angular application stored in Liferay

I am running on a Ubuntu 14.04 virtual host and I am trying to create some E2E tests using PROTRACTOR for and the application hosted in "Liferay".

For the login section (which does not require angular), the protractor test is β€œOK”, the page registers and moves correctly, but when I try to open the β€œdrop-down” menu in an application based on angularjs, the following code:

<select class = "form-control menu-select ng-pristine ng-valid" ng-model = "topTitlesData.topFiveDateRange" name = "topFiveDateRange" ng-options = "range.name for range in topTitlesData.topFiveDateRangeValues" ng-change = "" > < option value = "0" > Last day < /option><option value="1">Last 5 days</option > < option value = "2" > Last 7 days < /option><option value="3">Last 30 days</option > < option value = "4" > last 90 days < /option></select> 

I got this error log:

UnknownError: unknown error: angular not defined

 This is the test script on js: describe('pages with login', function() { it('should log in with a non-Angular page and select and option', funcion() { browser.ignoreSynchronization = true; browser.get('***************'); element(by.id('_58_login')).clear(); element(by.id('_58_login')).sendKeys('*******'); expect(element(by.id('_58_login')).getAttribute('value')).toEqual('*****'); element(by.id('_58_password')).sendKeys('*****', protractor.Key.ENTER); browser.get('***************'); //browser.ignoreSynchronization = false; var selects = element.all(by.model('topTitlesData.topFiveDateRange')); expect(selects.count()).toEqual(5); }); }); 

I wonder what I am missing?

I have nodejs, protractor, webadmin-manager, jdk7. * installed and updated

+6
source share
2 answers

Thank you, the problem was that the tests did not wait for angular to load on the page ... so I configure localhost with the application with "Grunt", "Yeoman" and Ruby + "ruby-compass" and avoided the lifeguard. I also installed

 allScriptsTimeout: 5000000, 

in the config.js file, and now the tests work fine.

0
source

Probably the problem is that your tests run until the browser page is fully loaded. The angular global variable has not yet been created. You can verify that all files were uploaded before the tests started by placing the following line in your protractor.conf.js onPrepare method:

 browser.driver.get(browser.baseUrl); 

This will take you to the page before starting any tests and ensures that everything is loaded.

+2
source

Source: https://habr.com/ru/post/982223/


All Articles