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]: Internal TypeError when chaining from an index of a ChainableElementArray #12917

Closed
1 task done
isc-aray opened this issue May 21, 2024 · 6 comments
Closed
1 task done

Comments

@isc-aray
Copy link

isc-aray commented May 21, 2024

Have you read the Contributing Guidelines on issues?

WebdriverIO Version

8.33.1

Node.js Version

20.12.2

Mode

Standalone Mode

Which capabilities are you using?

{
    browserName: 'chrome',
    "goog:chromeOptions": {
        args: [ "--start-maximized" ]
    }
}

What happened?

When I attempt to index a ChainableElementArray that doesn't match anything on the page, I get an internal error message "cannot read properties of undefined."

What is your expected behavior?

WebdriverIO should either apply normal element waiting for a single-element selection following a multi-element selection, or at least provide a clearer error message than the one seen above.

How to reproduce the bug.

The line of code that is triggering this error is:

await $$('[data-cy="list"]')[list - 1].$('[data-cy="new-card"]').click();

The issue does not occur if I put the following line in front of this:

await $('[data-cy="list"]').waitForExist();

Relevant log output

TypeError: Cannot read properties of undefined (reading 'options')
at wrapCommandFn (file:///[REDACTED]/node_modules/@wdio/utils/build/shim.js:80:36)
at file:///[REDACTED]/@wdio/utils/build/shim.js:105:69
at processTicksAndRejections (node:internal/process/task_queues:95:5)
at async World.<anonymous> ([MY FILE, REDACTED])
at async wrapPromiseWithTimeout (C:\[REDACTED]\node_modules\@cucumber\cucumber\src\time.ts:55:10)
at async Object.run (C:\[REDACTED]\node_modules\@cucumber\cucumber\src\user_code_runner.ts:86:16)
...


### Code of Conduct

- [X] I agree to follow this project's Code of Conduct

### Is there an existing issue for this?

- [X] I have searched the existing issues
@isc-aray isc-aray added Bug 🐛 Needs Triaging ⏳ No one has looked into the issue yet labels May 21, 2024
@isc-aray isc-aray changed the title [🐛 Bug]: <title> [🐛 Bug]: Internal TypeError when chaining from an index of a ChainableElementArray May 21, 2024
@christian-bromann christian-bromann added Reproducible Example Missing and removed Needs Triaging ⏳ No one has looked into the issue yet labels May 22, 2024
@wdio-bot
Copy link
Contributor

Thanks for raising this issue 🙏

Unfortunately we can't help you without a reproducible example in this matter. Please read our contributing guidelines on how to create a reproducible example. If you can't provide a reproducible example we will close this issue in 7 days.

If you have any questions please reach out to us on our Discord channel. We are happy to help you out there.

@isc-aray
Copy link
Author

I'm not allowed to have public repositories due to company policy, so thanks for nothing. That's what you get for free, I guess, but what a way to treat people who are trying to help!

@christian-bromann
Copy link
Member

christian-bromann commented May 22, 2024

I am not sure why you get so upset about this process! We kindly ask to provide a reproducible example as we maintainers can't spend hours of our time to try to reproduce something that you have already on your machine. Your issue is therefor no help because we can't prove on our side if this is related to WebdriverIO or a user error. If your company doesn't allow you to create code repositories on your account, that is not the projects issue and a problem of your company.

@isc-aray
Copy link
Author

I'm sorry, that was unprofessional, and much harsher than I should have been. I appreciate the need to reproduce the issue, but I find that the guidelines ask too much of someone reporting a bug, and far more than other open source tools that we use. You will, I hope, understand that I am not paid to help with software not produced by the company, and any code that I write as part of my employment belongs to my employer, and so I cannot share it publicly without permission from our legal department. I thought it would be helpful to draw attention to a bug that I encountered which nobody else seems to have reported, but if that sort of interaction is not appreciated, I will refrain in the future.

@christian-bromann
Copy link
Member

but I find that the guidelines ask too much of someone reporting a bug, and far more than other open source tools that we use.

Something that would work is just share code here in GitHub. For example I tried to reproduce this with this test:

import { browser, $$ } from '@wdio/globals'

describe('My Login application', () => {
    it('should login with valid credentials', async () => {
        await browser.url(`https://the-internet.herokuapp.com/login`)
        await $$('[data-cy="list"]')[123].$('[data-cy="new-card"]').click()
    })
})

this fails correctly with Index out of bounds! $$([data-cy="list"]) returned only 0 elements.. At this point I can't do any further investigations as I have no clue what circumstances were causing this bug to be thrown.

You will, I hope, understand that I am not paid to help with software not produced by the company, and any code that I write as part of my employment belongs to my employer, and so I cannot share it publicly without permission from our legal department.

You have shared code snippets above so it should be possible to share code snippets that reproduce the problem on an arbitrary public website. People that contribute to this project aren't paid either. Your company should have an interest to allow you to interact with Open Source projects in a meaningful way or should abstain from using Open Source completely.

I thought it would be helpful to draw attention to a bug that I encountered which nobody else seems to have reported, but if that sort of interaction is not appreciated, I will refrain in the future.

We appreciate your contribution to the project. If however the problem can not be explained with a reproducible example, it is not of much value for the folks maintaining the project.

@christian-bromann
Copy link
Member

Closing due to inactivity.

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

No branches or pull requests

3 participants