i'm running on a Ubuntu 14.04 virtual-host and i'm trying to create some E2E tests with PROTRACTOR for and Application hosted in "Liferay".
For the login section (that doesn't require angular) the test with protractor are Ok, the page logins and navigates correctly, but when i try to open a "drop-down" menu on the angularjs based app with 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 is 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'm running on a Ubuntu 14.04 virtual-host and i'm trying to create some E2E tests with PROTRACTOR for and Application hosted in "Liferay".
For the login section (that doesn't require angular) the test with protractor are Ok, the page logins and navigates correctly, but when i try to open a "drop-down" menu on the angularjs based app with 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 is 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'm wondering, what am i missing ?
i have nodejs, protractor, webadmin-manager,jdk7.* installed and updated
Share Improve this question edited Feb 9, 2015 at 17:54 Esteban asked Feb 9, 2015 at 17:10 EstebanEsteban 631 silver badge5 bronze badges 4-
1
are the spaces in
ng - model
,ng - options
, andng - change
typos? – Claies Commented Feb 9, 2015 at 17:35 - yes, those are typos. i'll correct them now.. – Esteban Commented Feb 9, 2015 at 17:53
- but i'm still having the same issue, those typos were created when i opened the ticket – Esteban Commented Feb 9, 2015 at 18:32
-
UnknownError: unknown error: angular is not defined
almost always occurs when angular doesn't initialize because it's missing a dependency somewhere. Can you post more of the HTML page where this error occurs? – Claies Commented Feb 9, 2015 at 18:36
2 Answers
Reset to default 3The problem is likely that your tests are running before the browser page is pletely loaded. The angular
global variable has not been created yet. You can ensure that all has been loaded before tests start by putting the following line in your protractor.conf.js
file's onPrepare
method:
browser.driver.get(browser.baseUrl);
This will navigate to the page before any tests start and ensure that all is loaded.
thank you, the issue was that the tests didn't wait till angular in loaded to the page... so i setup a localhost with the application with "Grunt", "Yeoman" and Ruby + "ruby-pass" gem and avoided liferay. I also setup
allScriptsTimeout: 5000000,
in the config.js file and now the tests is running okay.