Skip to content

[🐛 Bug]: refetching WebdriverIO.Elements in browser testing context doens't work #12528

@christian-bromann

Description

@christian-bromann

Have you read the Contributing Guidelines on issues?

WebdriverIO Version

latest

Node.js Version

latest

Mode

WDIO Testrunner

Which capabilities are you using?

any

What happened?

Given the following browser test:

    let loads = $('.lifecycle-loads-a').$$('li');
    await expect(loads).toBeElementsArrayOfSize(6);
    await expect(loads[0]).toHaveText('componentWillLoad-a');
    await expect(loads[1]).toHaveText('componentWillLoad-b');
    await expect(loads[2]).toHaveText('componentWillLoad-c');
    await expect(loads[3]).toHaveText('componentDidLoad-c');
    await expect(loads[4]).toHaveText('componentDidLoad-b');
    await expect(loads[5]).toHaveText('componentDidLoad-a');

This currently can cause race conditions as it seems that $$ fails to refetch the element properly, causing the following issue:

Failed to execute expect command "toHaveText": TypeError: el.getText is not a function

What is your expected behavior?

This should work. WebdriverIO has the index information and should refetch the elements and return the value with the same index.

How to reproduce the bug.

n/a

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

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions