Reputation: 650
I'm trying to get a basic Protractor test working (with Jasmine). Protractor is installed, selenium is running, and the example from the Protractor documentation is working.
However, when I copy the contents of the tested website ("The Basics" example on angularjs.org) to a jsfiddle (http://jsfiddle.net/yfUQ8/2/), the test errors:
Error: Error while waiting for Protractor to sync with the page: {}
My test looks like this:
describe('angularjs homepage', function() {
it('should greet the named user', function() {
browser.get('http://fiddle.jshell.net/yfUQ8/2/show/'); // fails
// browser.get('http://www.angularjs.org/'); // works
element(by.model('yourName')).sendKeys('Julie');
var greeting = element(by.binding('yourName'));
expect(greeting.getText()).toEqual('Hello Julie!');
});
});
When looking at the fiddle manually, everything seems to be working fine. Angular is bootstrapped using ng-app, and the test runs in 3 seconds (so it doesn't seem to be a timeout).
Upvotes: 2
Views: 845
Reputation: 164
Protractor needs to find the element with ngapp to synchronize. The default is 'body'. In your jsfiddle, I see:
<body>
<div ng-app>
If you set the rootEl property, your jsfiddle should work.
describe('angularjs homepage', function() {
it('should greet the named user', function() {
browser.get('http://fiddle.jshell.net/yfUQ8/2/show/');
browser.rootEl = 'div';
element(by.model('yourName')).sendKeys('Julie');
var greeting = element(by.binding('yourName'));
expect(greeting.getText()).toEqual('Hello Julie!');
});
});
Upvotes: 4