-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Provide documentation on how to use correctly browser.wait with protractor.ExpectedConditions #3578
Comments
Solved using element.isVisible in place of the ExpectedCondition:
i would suggest @cnishina that also for EC.invisibilityOf you adopt the same returning false in place of raising an exception. |
No damn, i'm still getting the error in a sporadic way even using the isDisplayed(). i confirm so that we are facing a regression on #2277 |
@evilaliv3 Hi, this issue is caused by a race condition between the isPresent and isDisplayed check. If the element is removed between both calls or while isDisplayed is executed you get a NoSuchElementError or a StaleElementReferenceError. This problem is solved for visibilityOf (https://github.com/angular/protractor/pull/3958/files), but it still exists for textToBePresentInElement and probably others. Before these changes are release in a future version your can monkey patch your ExpectedContions and use workaround functions that I put in an npm module https://www.npmjs.com/package/protractor-save-expected-conditions |
…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
…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
…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
I'm trying to use the protractor.ExpectedConditions together with browser.wait() but i'm sporadically failing with the error:
stale element reference: element is not attached to the page document.
The way i'm using the function is the following:
the reason that is causing the failure is probably that between the call to element(locator) and the usage of the element i've applications refresh that remove the element and cause the issue when the refernece is used.
i've not found any good documentation to use this routines without having this issue.
could you please provide some guidelines?
The text was updated successfully, but these errors were encountered: