Hi!
we have some problems with the behavior of IgnoreSynchronization since Protractor 5 and I was not able to find something regarding this in the changelog.
Here is a lightly adapted default protractor test case:
describe('angularjs homepage todo list', function() {
var browser2 = browser.forkNewDriverInstance();
browser2.ignoreSynchronization = true;
console.log(browser2); //returns ...internalIgnoreSynchronization: true;....
it('should add a todo', function() {
console.log(browser2) //returns ...internalIgnoreSynchronization: false;....
browser2.get('https://angularjs.org');
browser2.element(by.model('todoList.todoText')).sendKeys('write first protractor test');
browser2.element(by.css('[value="add"]')).click();
var todoList = browser2.element.all(by.repeater('todo in todoList.todos'));
expect(todoList.count()).toEqual(3);
expect(todoList.get(2).getText()).toEqual('write first protractor test');
todoList.get(2).element(by.css('input')).click();
var completedAmount = browser2.element.all(by.css('.done-true'));
expect(completedAmount.count()).toEqual(2);
});
});
The default console output outsite of it code block prints, that the internalIgnoreSynchronization value is set to true. After the entrance inside of the TC, the internalIgnoreSynchronization value changes to false.
Is it the correct behavior? Is it possible to find a workaround for it, otherwise we have to adapt a lot of testcases to set the ignoreSynchronization inside of each tc.
Thanks!
Regards,
Waldemar
faced similar issue with Protractor 5.1.1 which was not reproducible on 4.0.14
It is better now to use
browser. waitForAngularEnabled(false)
instead of
browser.ignoreSynchronization = true
http://www.protractortest.org/#/api?view=ProtractorBrowser.prototype.waitForAngularEnabled
Also try to put this into beforeEach()
describe('my suite', ()=>{
beforeEach(()=> {
browser.waitForAngularEnabled(false)
})
it('my test', ()=> {
...
})
})
I can suggest to put this into
onPrepare section of your config file or into beforeEach block. So it will be set before running all tests.
//Your protractor configuration file
let conf = {
// Some other options ...
onPrepare: () => {
browser.waitForAngularEnabled(false)
}
}
Ok, both (waitforAngularEnabled() and ignoreSynchronization) work inside of the beforeEach content.
But why it have to happen in a content block and not "describe-global" as before?
Setting waitForAngularEnabled now involves working with the control flow. I'm not exactly sure what's going on here, but it's probably some weird interaction with using the controlflow at the wrong time. Everything in the describe() block (but outside of a beforeEach(), it(), etc) is going to be run when the tests are set up, not when they're actually executed. All that stuff is run when Jasmine is setting up your tests, not when they're executing.
In general, put anything that interacts with the browser inside an it(), beforeEach(), beforeAll(), afterEach(), or afterAll() block. Avoid doing anything other than declaring variables outside of those blocks.
Most helpful comment
It is better now to use
browser. waitForAngularEnabled(false)instead of
browser.ignoreSynchronization = truehttp://www.protractortest.org/#/api?view=ProtractorBrowser.prototype.waitForAngularEnabled
Also try to put this into
beforeEach()I can suggest to put this into
onPreparesection of your config file or into beforeEach block. So it will be set before running all tests.