Discussions

Ask a Question
Back to All

How to work with Lazy Load with Protractor

At the moment I faced an issue when the project I am working with was refactored using ocLazy Load. From my side, I am an Automation QA working with Protractor v.5.1.2 .

Before implementing above-mentioned feature I was successfully using protractor involving such option as

browser.ignoreSynchronization = false;
But now as the app downloads js bundles separately, protractor seems to recognize the end of Angular $http and $timeout tasks, when the first js bundle is loaded. Whereas the page still is not ready for further work, because it loads next js bundle and I am getting such errors like:

No element found using locator
I have also tried

browser.waitForAngularEnabled(true);
but this is basically the same as ignoreSynchronization if you see the source code .

Such approaches might seem to be efficient

browser.sleep(5000);

or

browser.isElementPresent(by.css('a[ui-sref="some.stateLink"]'));

var $registerLink = element(by.css('a[ui-sref="some.stateLink"]'));

expect($registerLink.getText()).toEqual('Register Now');
or

var elem = by.css('a[ui-sref="some.stateLink"]');
browser.driver.wait(function() {
return browser.isElementPresent(elem);
}, 5000);
var $registerLink = element(elem);
expect($registerLink.getText()).toEqual('Register Now');
but they make tests fragile and there too much places in my code where I have to process it.

Does anybody faced such a problem? Thank you.