webdriverio/webdriverio

[🐛 Bug]: Middleware interfering with API: waitForDisplayed({ reverse: true })

Open

#13 253 ouverte le 1 août 2024

Voir sur GitHub
 (3 commentaires) (3 réactions) (0 assignés)JavaScript (1 793 forks)batch import
Bug 🐛help wanted

Métriques du dépôt

Stars
 (6 029 stars)
Métriques de merge PR
 (Merge moyen 15j 15h) (48 PRs mergées en 30 j)

Description

Have you read the Contributing Guidelines on issues?

WebdriverIO Version

v8

Node.js Version

20

Mode

Standalone Mode

Which capabilities are you using?

No response

What happened?

class MyPage {

  // A button to submit a form
  get submit(){ return $('#submit') }

  // A loading progress bar within the submit button that activates when submit is pressed
  get submitLoading(){ return this.submit.$('.loading') }

}

In my tests:

const myPage = new MyPage()

// Intent is to press the submit button and then wait for the loading to finish before moving on
await myPage.submit.click()

// If the loading is finished very briefly the entire form disappears, therefore the submit button dissappears
// WDIO middleware cannot find the submit button, so it stalls until waitForTimeout is reached and then errors

await myPage.submitLoading.waitForDisplayed({ reverse: true })

What is your expected behavior?

If the API has an option to wait for an element to not be displayed (waitForDisplayed({ reverse: true })) and

  • the element was built by nesting of elements like browser.$('#submit').$('.loading')
  • a parent element no longer exists

Then waitForDisplayed should not error with a timeout waiting for a parent element to exist

How to reproduce the bug.

class MyPage {

  // A button to submit a form
  get submit(){ return $('#submit') }

  // A loading progress bar within the submit button that activates when submit is pressed
  get submitLoading(){ return this.submit.$('.loading') }

}

In my tests:

const myPage = new MyPage()

// Intent is to press the submit button and then wait for the loading to finish before moving on
await myPage.submit.click()

// If the loading is finished very briefly the entire form disappears, therefore the submit button dissappears
// WDIO middleware cannot find the submit button, so it stalls until waitForTimeout is reached and then errors

await myPage.submitLoading.waitForDisplayed({ reverse: true })

Relevant log output

N/A

Code of Conduct

  • I agree to follow this project's Code of Conduct

Is there an existing issue for this?

  • I have searched the existing issues

Guide contributeur