dart 如何使用Flutter在Android上的Appium检查器中设置“text”属性?

c90pui9n  于 5个月前  发布在  Flutter
关注(0)|答案(1)|浏览(68)

我需要每个可见的UI组件(Flutter中的小部件)在使用Appium的Inspector检查时都是可区分的,并且具有accessibility-idtext属性。我还需要这两个属性是不同的。
我一直在使用Flutter的Semantics小部件来尝试实现这一点,但还没有找到设置text属性的方法。
假设我希望accessibility-id设置为“label”,text设置为“textContent”。

Semantics(
   label: 'label',
   child: Text('textContent'),
)

字符串
这就是上面的代码在使用Appium Inspector进行检查时的结果:x1c 0d1x
如果我将excludeSemantics属性设置为true:

Semantics(
   excludeSemantics: true,
   label: 'label',
   child: Text('textContent'),
)


accessibility-id设置正确,但Appium Inspector中仍然没有文本:

我还尝试了Semantics的“value”属性,它在iOS上运行良好,但在Android上它只是将其附加到accessibility-id的开头:

Semantics(
   excludeSemantics: true,
   label: 'label',
   value: 'value',
   child: Text('textContent'),
)


结果:

我不确定我想达到的目标是否可行。如果有人知道使用语义学或其他替代方法的解决方案,我将不胜感激。

wecizke3

wecizke31#

我不确定这是否能解决Appium的问题,但为什么不直接使用semanticsLabel属性呢?

Text(
  'An error occurred',
  semanticsLabel: 'error-occurred',
)

字符串

相关问题