We are trying to automate a publicly accessible website and click on one of the links, but the test fails with TimeOut Exception while locating the element as below:
From: Task: Protractor.waitForAngular() - Locator: By(link text, MY ACCOUNT) Sample conf and spec file below. Requesting help on how to solve this issue.
conf.js
exports.config = {
seleniumAddress: 'http://localhost:4444/wd/hub',
capabilities: {
'browserName': 'chrome'
},
specs: ['test.js']
};
test.js
describe('test', function() {
it('should navigate', function(done) {
browser.get('https://ww2.tracfone.com');
element(by.linkText('MY ACCOUNT')).click();
done();
});
};
Found the root cause for the issue you were seeing for your webPage. Looks like your site continuously polls $timeout or $http, Protractor will wait indefinitely and time out.
I have monitored the http traffic below and see that your app polls at frequent intervals and Protractor just waits. Checkout the screen grab below.(The green marks in the timeline indicating $http calls to - https://ww2.tracfone.com/cgi-bin/tealeaf.pl )
More details on why you are seeing this error is documented here. ok. Coming to the different solutions for this, there are multiple work-arounds for this. I will just talk in brief about the alternatives and leave it to you to choose the best one.
IgnoreSynchronization: Turn this flag -
browser.ignoreSynchronization
to false before thebrowser.get()
and continue with the test flow and set the flag to true again for other pages Check hereInterval.js : I am no expert on this but you can explore more here
Try with different timeOut configurations and see if your app polling stops after some time
allScriptsTimeout: 120000, getPageTimeout: 120000, jasmineNodeOpts: { defaultTimeoutInterval: 120000 }
I setup a sample project based on the items you've posted and this test appears to be working for me.I'm not sure why you are getting the timeout that is usually associated with pages that are not angular but setting
browser.ignoreSynchronization = true
helped get past this error.