This repository has been archived by the owner on Jul 29, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
ExpectedConditions.invisibilityOf cannot reliably be used to wait for an element to be removed from the DOM #3777
Comments
We could actually probably solve this fairly easily by removing the |
massimocode
added a commit
to massimocode/protractor
that referenced
this issue
Dec 17, 2016
massimocode
added a commit
to massimocode/protractor
that referenced
this issue
Dec 17, 2016
@massimocode @sjelin I have the same problem and wrote some tests to reproduce the problem. https://github.com/tilmanpotthof/race-condition-in-expected-condition-visibility-of I also added a workaround, which I use in a project that uses the promise error callback. |
heathkit
pushed a commit
that referenced
this issue
Jan 12, 2017
… a race condition (#3777) Handle NoSuchElementError in the expected condition visibilityOf, which occurred when an element disappears between the isPresent() and isDisplayed() check.
sjelin
added a commit
to sjelin/protractor
that referenced
this issue
Jan 13, 2017
…lements Expected conditions used `presenceOf` and `visibilityOf` to check that it's referencing elements which actually exist on the page, but there is a race condition with this strategy: an element could disappear after the `presenceOf`/`visibilityOf` check but before other checks, causing an error to be thrown. This PR handles this race condition in two ways: 1. `ElementFinder`'s `isEnabled`, `isDisplayed`, and `isSelected` functions now return false if no such element exists, rahter than throwing an error 2. `ExpectedConditions`'s `textToBePresent` and `textToBePresentInElementValue` now check for errors and also return false in those cases This is a general solution to the problem referenced in angular#3777 and angular#3958.
sjelin
added a commit
to sjelin/protractor
that referenced
this issue
Jan 13, 2017
…lements Expected conditions used `presenceOf` and `visibilityOf` to check that it's referencing elements which actually exist on the page, but there is a race condition with this strategy: an element could disappear after the `presenceOf`/`visibilityOf` check but before other checks, causing an error to be thrown. This PR handles this race condition in two ways: 1. `ElementFinder`'s `isEnabled`, `isDisplayed`, and `isSelected` functions now return false if no such element exists, rahter than throwing an error 2. `ExpectedConditions`'s `textToBePresent` and `textToBePresentInElementValue` now check for errors and also return false in those cases This is a general solution to the problem referenced in angular#3777 and angular#3958.
heathkit
pushed a commit
that referenced
this issue
Jan 27, 2017
…ibility (#4006) Add test cases to reproduce the missing element race conditions possible in expected condition methods `visibilityOf`, `textToBePresentInElement`, `textToBePresentInValue` and `elementToBeClickable`. Add error handler `falseIfMissing` to all expected conditions that depend on the presence of an element. Expected conditions check the presence of an element before other checks, but when an element is removed exactly in the moment after the `isPresent` and before `isDisplayed` in `visibilityOf` the condition used to fail. This solution does not handle missing elements in (`isEnable`, `isDisplayed`, `isSelected`) and focused only on expected conditions (see #3972) This problem was also referenced in #3578 and #3777
igniteram
pushed a commit
to igniteram/protractor
that referenced
this issue
Feb 21, 2017
… a race condition (angular#3777) Handle NoSuchElementError in the expected condition visibilityOf, which occurred when an element disappears between the isPresent() and isDisplayed() check.
igniteram
pushed a commit
to igniteram/protractor
that referenced
this issue
Feb 21, 2017
…ibility (angular#4006) Add test cases to reproduce the missing element race conditions possible in expected condition methods `visibilityOf`, `textToBePresentInElement`, `textToBePresentInValue` and `elementToBeClickable`. Add error handler `falseIfMissing` to all expected conditions that depend on the presence of an element. Expected conditions check the presence of an element before other checks, but when an element is removed exactly in the moment after the `isPresent` and before `isDisplayed` in `visibilityOf` the condition used to fail. This solution does not handle missing elements in (`isEnable`, `isDisplayed`, `isSelected`) and focused only on expected conditions (see angular#3972) This problem was also referenced in angular#3578 and angular#3777
bodyduardU
pushed a commit
to bodyduardU/protractor
that referenced
this issue
Dec 5, 2022
…ibility (#4006) Add test cases to reproduce the missing element race conditions possible in expected condition methods `visibilityOf`, `textToBePresentInElement`, `textToBePresentInValue` and `elementToBeClickable`. Add error handler `falseIfMissing` to all expected conditions that depend on the presence of an element. Expected conditions check the presence of an element before other checks, but when an element is removed exactly in the moment after the `isPresent` and before `isDisplayed` in `visibilityOf` the condition used to fail. This solution does not handle missing elements in (`isEnable`, `isDisplayed`, `isSelected`) and focused only on expected conditions (see angular/protractor#3972) This problem was also referenced in angular/protractor#3578 and angular/protractor#3777
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Protractor build 4.0.11
invisibilityOf states the following in the API documentation:
An expectation for checking that an element is either invisible or not present on the DOM. This is the opposite of 'visibilityOf'
Please see the following stack trace that we get intermittently from our build server when using invisibilityOf with browser.wait to wait for an element to be removed from the DOM:
The specific lines I would like to draw attention to are:
The call stack indicates that the error is being thrown when evaluating
elementFinder.isDisplayed.bind(elementFinder)
in the following line of code:I believe the reason this happened is that the element was removed from the DOM between the
presenceOf(elementFinder)
andelementFinder.isDisplayed.bind(elementFinder)
I have since changed all our browser.wait statements where we were using invisibilityOf to wait for an element to be removed from the DOM to use stalenessOf instead. The problem has not reoccurred.
My suggestion is to update the API documentation as per this PR https://github.com/angular/protractor/pull/3775/files as I believe this might be easier than rewriting this check to be "atomic".
The text was updated successfully, but these errors were encountered: