flutter - 试图在 flutter driver 中获取多个元素(QA 环境)

标签 flutter dart testing

我已经成功地使用 commonfinders 在 flutter driver 中获取单个元素,但是当涉及到可能具有相同类型的多个元素时,它总是会抛出错误。我知道这是设计使然。如果有人可以建议一种获取多个元素并将它们存储在数组/列表中的方法,我将不胜感激,这样我就可以通过它们的索引访问它们。类似的功能是,在 selenium 中,它允许您对多个元素使用 findElements(...) 而 findElement(...) 允许您搜索单个元素。

最佳答案

这是根据类型获取第一个元素的方法

find.descendant(
      of: find.byValueKey(parentWidgetKey),
      matching: find.byType('CheckBox'),
      firstMatchOnly: true,
);

如果您有多个复选框,只需为它们的父项分配一个键,通过键获取父项,通过类型获取复选框并将 firstMatchOnly 标志设置为 true

关于flutter - 试图在 flutter driver 中获取多个元素(QA 环境),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49398933/

相关文章:

Symfony2 phpunit在不同环境下运行测试

testing - 通过标签将 VCR 与 Cucumber 一起使用

json - 参数类型 'x' 无法分配给参数类型 'x'

ios - 为什么 Flutter 手机身份验证在我的真实设备上不起作用

flutter - 在Flutter上的时间之前关闭模态底部表会导致黑屏

dart - 本地存储:将Map <String,String>添加到存储的列表中

http - Flutter http 客户端给出 FormatException : Unexpected character (at character 1) &lt;! DOCTYPE html>

javascript - 在 JavaScript 中使用 Chai 测试无效参数

firebase - Flutter Firebase 应用内消息

flutter - 文本小部件未显示在 ListTile flutter 中