Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NoSuchElementError should be suppressed for assert[.not].present() assertion in new Elem API. #4304

Open
garg3133 opened this issue Nov 18, 2024 · 3 comments

Comments

@garg3133
Copy link
Member

garg3133 commented Nov 18, 2024

Description

When we do browser.element.find(selector).assert.present(), if the element is not found, we get the NoSuchElementError error, but in case of assert.present, this error should be suppressed since the failure of the assertion would anyway signify that the element is not present.

image

The same also goes for the .assert.not.present() assertion. In this case, if the element is not present, the assertion should normally pass without the NoSuchElementError.

image
(The test should pass with 0 errors unlike in the above screenshot.)

@Pikachu-345
Copy link

Hey @garg3133 I am a beginner at Open Source. So can I contribute to this issue, if yes. can you please specify what parts of the projects do I need to look at for fixing this issue.

Regards,
Thank you.

@garg3133
Copy link
Member Author

garg3133 commented Nov 29, 2024

Hey, the scoped-element.js file and the assert/element-assertions.js file are the two main files you should try to look at to solve this issue. Also, you can refer to the implementation of the isPresent command in the new Element API, which also automatically suppresses the NoSuchElementFound error as required in this issue: https://github.com/nightwatchjs/nightwatch/pull/4216/files

You might need to use the VSCode JS Debugger to understand how this part of the code works before solving this issue.

@Pikachu-345
Copy link

Pikachu-345 commented Nov 29, 2024

Okay, will be back soon with the solution.

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

No branches or pull requests

2 participants