Skip to content

findElements command does not implicitly wait for elements #41

Description

@tnmma96

According to the definition of WebElement.findElement() and WebElement.findElements(), they will be affected by the implicit wait time before returning results.

However, I notice that findElements command returns almost immediately even when there is no element found yet, unlike findElement command which actually respects the implicit wait time and only returns after finishing waiting.


On inspecting the code, I found that ElementHelper.findElements() decides to wait for elements based on evaluatePresence parameter, which is false by default.

if (evaluatePresence) {
await waitForElementExist(FlutterElement.fromBy(finder),
timeout: Duration(
milliseconds: FlutterDriver.instance.settings
.getSetting(FlutterSettings.flutterElementWaitTimeout)));
if (elements.isEmpty) {
throw ElementNotFoundException("Unable to locate element");
}
}

When the method is called from ElementHelper.findElement(), evaluatePresence is explicitly set to true which corresponds with the behavior observed above: findElement command waits for elements and only returns after timeout.

List<Finder> elementList =
await findElements(by, contextId: contextId, evaluatePresence: true);

However, when it's called from FindElementsHandler.handle(), evaluatePresence is not explicitly set, therefore (I assume) the implicit wait is not executed.

matchedByList =
await ElementHelper.findElements(by, contextId: contextId);

Can this be considered a bug? If it is, can you take a look and help resolve it?
Thank you in advance.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions