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

isExisting() returns Error if DOM is not present #605

Closed
BavithiraG opened this issue Apr 17, 2024 · 4 comments
Closed

isExisting() returns Error if DOM is not present #605

BavithiraG opened this issue Apr 17, 2024 · 4 comments
Labels

Comments

@BavithiraG
Copy link

Describe the bug
isExisting() is expected to return false if the DOM is not present. Instead it returns below error
ERR: - Error: No DOM element found using the control selector

To Reproduce
invoke .isExisting() on any element not present

Expected behavior
isExisting() should return false

Logs/Console Output
[browser wdi5] ERR: - Error: No DOM element found using the control selector {"


**Screenshots**
if applicable, add screenshots to help explain your problem.

**Runtime Env (please complete the following information):**

- `wdi5/wdio-ui5-service`-version: 2.0.6
- `UI5` version: 3.9.0
- `wdio`-version (output of `wdio --version`): 8.32.3
- `node`-version (output of `node --version`): v18.14.0

**Additional context**
Add any other context about the problem here,
e.g. any options the target browser is started with like `--headless` or
if the tests run in a CI environment
@BavithiraG BavithiraG changed the title isExisting() returns Error if DOM present isExisting() returns Error if DOM is not present Apr 17, 2024
@vobu
Copy link
Contributor

vobu commented Apr 19, 2024

this is a little hard to grasp as there's no minimal reproducible sample provided, not even sample code.
yet I'm guesstimaiting you're referring to the wdio (not wdi5!) element method .isExisiting()https://webdriver.io/docs/api/element/isExisting
wdi5 sits on top wdio. So if you're doing something along the line
await exists = browser.asControl(selector).$().isExisting(); expect(exists).toBe(false)
this will fail b/c browser.asControl() can't retrieve the DOM element (as it doesn't exist, meh) and subsequent operations on that are not possible.
Instead, please use
await exists = await browser.asControl(selector).isInitialized(); expect exists.toBeFalsy()

Copy link

hey 👋 - silence for 30 days 🤐 ... anybody? 😀

@github-actions github-actions bot added the stale label May 20, 2024
Copy link

github-actions bot commented Jun 3, 2024

closed 📴 because silencio 🤫 since an additional 14 days after staleness 📠

@github-actions github-actions bot closed this as completed Jun 3, 2024
@kingages
Copy link

kingages commented Jun 28, 2024

I tried your suggestion but I get error in wdi5 log although my test is passed. It is confusing. I would expect that error would go away.

async deleteAssessmentDisplayed(isDisplayed: boolean) { const deleteButtonExists = await (await browser.asControl(await this.getDeleteButtonSelector())).isInitialized(); await expect(deleteButtonExists).toBe(isDisplayed); }

[0-3] [wdi5] successfully initialized wdio-ui5 bridge [0-3] [wdi5] creating internal control with id saprct.assessments::AssessmentsObjectPage [0-3] [wdi5] call of function _getControl() returned: "sap.rct.assessments::AssessmentsObjectPage" [0-3] [wdi5] _asControl() needed 44428.126000000004 for saprct.assessments::AssessmentsObjectPage [0-3] [wdi5] creating internal control with id CustomAction::CustomDelete$/ [0-3] [wdi5] call of _getControl() failed because of: Error: No DOM element found using the control selector {"id":{}} [0-3] [wdi5] error retrieving control: CustomAction::CustomDelete$/ [0-3] [wdi5] _asControl() needed 430.14708399999654 for CustomAction::CustomDelete$/ [0-3] Error in "2: Then the user should have view-only access"

This works better for me:

async deleteAssessmentDisplayed(isDisplayed: boolean) { const deleteButtonExists = (await browser.allControls(await this.getDeleteButtonSelector())).length; await expect(Boolean(deleteButtonExists)).toBe(isDisplayed); }

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

No branches or pull requests

3 participants