You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I use const elementIsHere = browser.element('#myElement').isPresent() I expect a boolean of true or false to be returned to the elementIsHere constant variable, but if the element is not present in the DOM within the timeout the test returns an element not found exception. Suppress not found errors does not help in this instance. It's implied through the name it should return true if present and false if not.
There are cases in our testing where we sometimes need to branch logic when there are A/B versions of the UI served so the test can handle it. So, for example, if "something" is present then do this / else do something else.
.isPresent in its current form works the same as .waitUntilElementPresent() which I'd argue serve or should serve different purposes--the former should handle cases where the element may never be present where the latter expects that it should eventually appear within the timeout.
As a workaround I end up using findElements with a compound selector of something guaranteed to be in the DOM and the selector I'm waiting for then I see if the length of the elements found is greater than 1 which works but not as direct.
Looking at this, since you're using element(...) it's not really getting to the point where it does isPresent is called. element(...) will do auto waiting for you which leads to it acting like waitUntilElementPresent. This is
We also have #4055 that is going to serve exactly that purpose, it would only return true or false results instead of throwing an error when the element is not found.
There is already an active PR on the issue which we hope to merge and release soon.
Description of the bug/issue
When I use
const elementIsHere = browser.element('#myElement').isPresent()
I expect a boolean of true or false to be returned to theelementIsHere
constant variable, but if the element is not present in the DOM within the timeout the test returns an element not found exception. Suppress not found errors does not help in this instance. It's implied through the name it should return true if present and false if not.There are cases in our testing where we sometimes need to branch logic when there are A/B versions of the UI served so the test can handle it. So, for example, if "something" is present then do this / else do something else.
.isPresent in its current form works the same as .waitUntilElementPresent() which I'd argue serve or should serve different purposes--the former should handle cases where the element may never be present where the latter expects that it should eventually appear within the timeout.
As a workaround I end up using findElements with a compound selector of something guaranteed to be in the DOM and the selector I'm waiting for then I see if the length of the elements found is greater than 1 which works but not as direct.
Steps to reproduce
In a test use
const elementIsHere = browser.element('#this-doesnt-exist').isPresent()
The test will throw a not found exception instead of setting elementIsHere to false.
Sample test
No response
Command to run
No response
Verbose Output
No response
Nightwatch Configuration
No response
Nightwatch.js Version
3.5
Node Version
20
Browser
Chrome 123
Operating System
Windows 11
Additional Information
No response
The text was updated successfully, but these errors were encountered: