nightwatchjs / nightwatch

Integrated end-to-end testing framework written in Node.js and using W3C Webdriver API. Developed at @browserstack
https://nightwatchjs.org
MIT License
11.75k stars 1.3k forks source link

Add `isPresent` command. #4216

Open dikwickley opened 1 month ago

dikwickley commented 1 month ago

Thanks in advance for your contribution. Please follow the below steps in submitting a pull request, as it will help us with reviewing it quicker.

The isPresent command was quite tricky as there were few edge cases we had to solve. The main one being when the element in not present, we don't want to show the Timeout Error if there is a isPresent command chained (which should ideally return false).

I solved this by checking if the next sibling of a find command is an elementIsPresent command. It still takes 5 seconds to try to resolve the element.

If this approach looks good, I can add some tests for this too.

Sanity for elements that are not present:

Screenshot 2024-06-03 at 1 24 56 AM
github-actions[bot] commented 1 month ago

Status

pujagani commented 1 month ago

There are some failing tests. Not sure if it is due to the changes made here. Can you help take a look? Thank you!

dikwickley commented 1 month ago

@pujagani yes, fixed those. There was a missing check for outofbounds index.

AutomatedTester commented 1 month ago

I think the test that is failing is flakey.

I can't see a test for this change can we add one?

dikwickley commented 4 weeks ago

@garg3133 @AutomatedTester ready for review!