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

[🐛 Bug]: Cannot command on elements coerced into an array: Malformed type for "elementId" parameter #12706

Open
3 tasks done
nextlevelbeard opened this issue Apr 16, 2024 · 2 comments
Labels
Bug 🐛 good first pick a reasonable task to start getting familiar with the code base help wanted Issues that are free to take by anyone interested

Comments

@nextlevelbeard
Copy link
Member

Have you read the Contributing Guidelines on issues?

WebdriverIO Version

latest

Node.js Version

20.11.1

Mode

WDIO Testrunner

Which capabilities are you using?

No response

What happened?

Using the feature described in #8609 and implemented in #8736.

When coerceing elements into an element array and then mapping the elements to a command, it throws an error.

What is your expected behavior?

Feature #8609 should be working but appears to have regressed.

How to reproduce the bug.

// Should work, doesn't
const texts = await $$([
    $('.item'),
    $('button'),
    $('[data-value="hello"]')
]).map(e => e.getText())

// Workaround
const texts = await Promise.all([
    $('.item'),
    $('button'),
    $('[data-value="hello"]')
]).map(e => e.getText())

Relevant log output

Malformed type for "elementId" parameter of command getElementText
Expected: string
Actual: function

For more info see https://w3c.github.io/webdriver/#dfn-get-element-text

    at file:///Users/user/repos/repo/e2e/node_modules/webdriverio/build/commands/browser/waitUntil.js:43:15
    at async Browser.wrapCommandFn (file:///Users/user/repos/repo/e2e/node_modules/@wdio/utils/build/shim.js:90:29)
    at async Scenario.<anonymous> (file:///Users/user/repos/repo/e2e/steps/my.steps.ts:1:1)

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
@nextlevelbeard nextlevelbeard added Bug 🐛 Needs Triaging ⏳ No one has looked into the issue yet labels Apr 16, 2024
@christian-bromann
Copy link
Member

// Should work, doesn't

As per my comment the passed in elements can't be from type ChainablePromiseElement, so your example works if you do:

const texts = await $$([
    await $('.item'),
    await $('button'),
    await $('[data-value="hello"]')
]).map(e => e.getText())

I think it can be easily extended to support ChainablePromiseElement types as well. Contributions are welcome.

@christian-bromann christian-bromann added help wanted Issues that are free to take by anyone interested good first pick a reasonable task to start getting familiar with the code base and removed Needs Triaging ⏳ No one has looked into the issue yet labels Apr 16, 2024
@wdio-bot
Copy link
Contributor

Thanks for reporting!

We greatly appreciate any contributions that help resolve the bug. While we understand that active contributors have their own priorities, we kindly request your assistance if you rely on this bug being fixed. We encourage you to take a look at our contribution guidelines or join our friendly Discord development server, where you can ask any questions you may have. Thank you for your support, and cheers!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug 🐛 good first pick a reasonable task to start getting familiar with the code base help wanted Issues that are free to take by anyone interested
Projects
None yet
Development

No branches or pull requests

3 participants