webdriverio/webdriverio

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

Open

#13,253 opened on 2024幎8月1日

GitHub で芋る
 (3 comments) (3 reactions) (0 assignees)JavaScript (1,793 forks)batch import
Bug 🐛help wanted

Repository metrics

Stars
 (6,029 stars)
PR merge metrics
 (平均マヌゞ 15d 15h) (30d で 48 merged PRs)

説明

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

コントリビュヌタヌガむド