"angular is not defined" error while executing Protractor test on angular application stored in Liferay

Esteban picture Esteban · Feb 9, 2015 · Viewed 7.9k times · Source

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

i'm wondering, what am i missing ?

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

Answer

Andrew Eisenberg picture Andrew Eisenberg · Feb 10, 2015

The problem is likely that your tests are running before the browser page is completely 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.