I am experiencing issues with Protractor recognizing that Angular is loaded and operational. Upon opening Chrome, my application fully loads in the browser, confirming that Angular is indeed loaded and running correctly.
Here is the configuration file:
exports.config = {
seleniumServerJar: 'C:/Dev/PrismWeb/selenium/selenium-server-standalone-2.35.0.jar',
seleniumPort: null,
chromeDriver: 'C:/Dev/PrismWeb/selenium/chromedriver.exe',
seleniumArgs: [],
seleniumAddress: null,
allScriptsTimeout: 110000,
specs: ['c:/dev/prismweb/test/e2e/*.js'],
capabilities: {'browserName': 'chrome'},
baseUrl: 'http://localhost:8080',
rootElement: 'html',
jasmineNodeOpts: {
onComplete: null,
isVerbose: true,
showColors: true,
includeStackTrace: true,
defaultTimeoutInterval: 30000
}
};
I am attempting to run a single test which fails due to Protractor being unable to locate Angular.
The Test:
describe('homepage loads: ', function(){
var ptor;
ptor = protractor.getInstance();
beforeEach(function(){
ptor.get('/');
});
it('should load the prism homepage: ', function(){
var usernameField = ptor.findElement(protractor.By.id("username"));
//expect(usernameField).toBeDefined();
});
});
This error message is displayed:
UnknownError: javascript error: angular is not defined (Session info: chrome=30.0.1599.69) (Driver info: chromedriver=2.2,platform=Windows NT 6.1 SP1 x86_64) (WARNING: The server did not provide any stacktrace information) Command duration or timeout: 19 milliseconds Build info: version: '2.35.0', revision: 'c916b9d', time: '2013-08-12 15:42:01' System info: os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.7.0_21' Session ID: 1ef7dcd7c5fc9c4e9e1dede050002adf Driver info: org.openqa.selenium.chrome.ChromeDriver Capabilities [{platform=XP, acceptSslCerts=true, javascriptEnabled=true, browserName=chrome, chrome={chromedriverVersion=2.2}, rotatable=false, locationContextEnabled=true, version=30.0.1599.69, cssSelectorsEnabled=true, databaseEnabled=true, handlesAlerts=true, browserConnectionEnabled=false, webStorageEnabled=true, nativeEvents=true, applicationCacheEnabled=false, takesScreenshot=true}]
I have attempted moving the ng-app attribute to the body tag, but the error persists. Additionally, we have an ng-controller attribute on the html tag which I also experimented with moving to the body tag while leaving the ng-app attribute intact on the html tag. Unfortunately, this did not resolve the issue. Any insights into why this failure occurs would be greatly appreciated.
EDIT: I made some updates to the test above to incorporate manual bootstrapping efforts. The script tags for Angular and its modules are placed at the end of the page right before the closing BODY tag. The HTML tag still contains the ng-app="myApp" attribute and the ng-controller="baseController" attribute. When attempting to manually bootstrap the app in the test, I encounter the following error:
ReferenceError: angular is not defined
One concern is that one of the modules we utilize requires "$" to be linked to jQuery, so we map it as follows:
<script type="text/javascript">
var $jq=jQuery.noConflict();
var $=jQuery.noConflict();
</script>
Where the ng-app is included:
<!DOCTYPE html>
<html ng-app="prismApp" ng-controller="baseController">
<head>