Skip to content
This repository was archived by the owner on Jul 29, 2024. It is now read-only.

Make it easier to control when ignoreSynchronization is off or on #1939

Closed
juliemr opened this issue Mar 18, 2015 · 9 comments
Closed

Make it easier to control when ignoreSynchronization is off or on #1939

juliemr opened this issue Mar 18, 2015 · 9 comments

Comments

@juliemr
Copy link
Member

juliemr commented Mar 18, 2015

It's kind of difficult to know how it interacts with the control flow at the moment.

@hankduan
Copy link
Contributor

Can we just wrap all our command in control flow, and make a function that sets ignoreSynchronization in control flow.

i.e. browser.get (simplified to capture the idea)
now:

if (ignoreSynchronization) {driver.get(...)}
else {waitForAngular(); driver.get(...)}

after:

flow.execute(function() {
  if (ignoreSynchronization) {driver.get(...)}
  else {waitForAngular(); driver.get(...)}
})

and make

setIgnoreSynchronization = function(val) {
  flow.execute(function() {
    ignoreSynchronization = val;
  })
}

This will make cloning browsers more robust too

@juliemr
Copy link
Member Author

juliemr commented Mar 18, 2015

Yeah, I think that's reasonable and probably the simplest way to do it. The hardest bit will be making clear docs about usage :)

@smhc
Copy link
Contributor

smhc commented Mar 19, 2015

If this were implemented.. I wonder if synchronisation could be turned off automatically by 'get' operations, and on when an action is performed that interacts with the page. i.e

waitForAngular()
click() - turn on sync
waitForAngular()
getText() - turn off sync
getText() - turn off sync
getText() - turn off sync
getText() - turn off sync
getText() - turn off sync 
click() - turn on sync
waitForAngular()
getText()  - turn off sync

Does that make sense? I think in some cases it could result in a fairly reasonable performance improvement, without the overhead of having to manage the sync on and off manually.
I don't know how practical it is however.

@juliemr
Copy link
Member Author

juliemr commented Mar 19, 2015

@smhc I think that's out of scope for this change, but I'm working on an entirely new way of doing waits that will incorporate this sort of smart waiting. Stay tuned :)

@juliemr juliemr self-assigned this Mar 23, 2015
@martin770
Copy link
Contributor

Any update on this? I was wondering about even just retrieving browser.ignoreSynchronization as a promise or setting/getting within the context of the control flow somehow.

setIgnoreSynchronization = function(arg) {
    arg = arg === undefined ? true : arg;
    controlFlow().execute(function() { browser.ignoreSynchronization = arg };
}
getIgnoreSynchronization = function() {
    return controlFlow().execute(function() { return browser.ignoreSynchronization });
}

So then in waitForAngular() you can have

this.getIgnoreSynchronization.then(function(shouldNotSync) {
    if (shouldNotSync) {
      return
    } else {
      ... waitForAngularStuff ...  
    }
}

It would be nice to have the ability to use ignoreSynchronization within various points in the control flow. It seems to work ok when changing in onPrepare, beforeEach, or afterEach, but it isn't very useful when trying to change in the middle of a test.

@smhc
Copy link
Contributor

smhc commented Apr 19, 2016

Has this been addressed by cae175c ?

@martin770
Copy link
Contributor

@smhc: No, cae175c doesn't mention the controlFlow. So while the plugin may be able to change the synchronization value during onPrepare, beforeEach, etc, it won't be able to change the value multiple times within the body of the test. To write the failing test, you would need to turn off synchronization, perform some action, expect some thing, turn it back on, perform some other action, expect some thing.

By the way, I like your previous suggestion of waitForAngular after click (and navigate, sendKeys, etc), and have been thinking about incorporating it into my page objects. It would be interesting to see if there is any performance benefit.

@juliemr
Copy link
Member Author

juliemr commented Jul 14, 2016

We'll have an opportunity to fix this when moving to Blocking Proxy. See #3375

@heathkit
Copy link
Contributor

In #3813, we added browser.waitForAngularEnabled(). This method will replace setting the browser.ignoreSynchronization proxy in future versions of Protractor.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants