Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Protractor 5.1 - Wrong IgnoreSynchronization Behavior? #4187

Closed
wsieb opened this issue Mar 28, 2017 · 4 comments
Closed

Protractor 5.1 - Wrong IgnoreSynchronization Behavior? #4187

wsieb opened this issue Mar 28, 2017 · 4 comments

Comments

@wsieb
Copy link

wsieb commented Mar 28, 2017

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

@wsieb wsieb changed the title Protractor 5.1 - IgnoreSynchronization Behavior Protractor 5.1 - Wrong IgnoreSynchronization Behavior Mar 29, 2017
@wsieb wsieb changed the title Protractor 5.1 - Wrong IgnoreSynchronization Behavior Protractor 5.1 - Wrong IgnoreSynchronization Behavior? Mar 29, 2017
@pankumarptc
Copy link

faced similar issue with Protractor 5.1.1 which was not reproducible on 4.0.14

@Xotabu4
Copy link

Xotabu4 commented Apr 5, 2017

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)
    }
}

@wsieb
Copy link
Author

wsieb commented Apr 12, 2017

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?

@heathkit
Copy link
Contributor

heathkit commented May 1, 2017

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.

@heathkit heathkit closed this as completed May 1, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants