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.
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
findElementscommand returns almost immediately even when there is no element found yet, unlikefindElementcommand 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 onevaluatePresenceparameter, which is false by default.appium-flutter-server/server/lib/src/utils/element_helper.dart
Lines 47 to 56 in 78ba97a
When the method is called from
ElementHelper.findElement(),evaluatePresenceis explicitly set to true which corresponds with the behavior observed above:findElementcommand waits for elements and only returns after timeout.appium-flutter-server/server/lib/src/utils/element_helper.dart
Lines 27 to 28 in 78ba97a
However, when it's called from
FindElementsHandler.handle(),evaluatePresenceis not explicitly set, therefore (I assume) the implicit wait is not executed.appium-flutter-server/server/lib/src/handler/find_elements.dart
Lines 29 to 30 in 78ba97a
Can this be considered a bug? If it is, can you take a look and help resolve it?
Thank you in advance.