webdriverio/webdriverio

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

Open

#13.253 aperta il 1 ago 2024

Vedi su GitHub
 (3 commenti) (3 reazioni) (0 assegnatari)JavaScript (1793 fork)batch import
Bug 🐛help wanted

Metriche repository

Star
 (6029 star)
Metriche merge PR
 (Merge medio 15g 15h) (48 PR mergiate in 30 g)

Descrizione

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

Guida contributor