Skip to content

elems.toBeElementsArrayOfSize(0) fails all the time #1506

@christian-bromann

Description

@christian-bromann

It is not possible to verify if a set of elements has 0 elements. Having the following assertion:

elems = $$('span');
await expect(elems).toBeElementsArrayOfSize(1);

will fail all the time due to:

 Failed to execute expect command "toBeElementsArrayOfSize": Error: selector needs to be typeof `string` or `function`
    at Browser.findElements (file:///path/to/project/test/wdio/node_modules/webdriverio/build/utils/index.js:308:11)
    at Browser.$$ (file:///path/to/project/test/wdio/node_modules/webdriverio/build/commands/browser/$$.js:46:30)
    at Browser.wrapCommandFn (file:///path/to/project/test/wdio/node_modules/@wdio/utils/build/shim.js:88:38)
    at async refetchElements (file:///path/to/project/test/wdio/node_modules/expect-webdriverio/lib/util/refetchElements.js:5:24)
    at async waitUntil (file:///path/to/project/test/wdio/node_modules/expect-webdriverio/lib/matchers/elements/toBeElementsArrayOfSize.js:25:20)
    at async waitUntil (file:///path/to/project/test/wdio/node_modules/expect-webdriverio/lib/utils.js:23:43)
    at async Object.toBeElementsArrayOfSize (file:///path/to/project/test/wdio/node_modules/expect-webdriverio/lib/matchers/elements/toBeElementsArrayOfSize.js:24:18)
    at async BrowserFramework.#handleExpectation (file:///path/to/project/test/wdio/node_modules/@wdio/runner/build/browser.js:297:28)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions