android - React native + Appium,如何找到一个元素

标签 android react-native appium

我正在尝试(太长时间......)让 appium 与 React Native 一起工作,但似乎找不到任何元素。

我正在使用模拟器、Nexus 6、android 6.0、ubuntu、appium 1.6.0、RN 0.39.2。

我正在尝试让最基本的示例起作用:

// foo.js
render () {
  return (
    <Text>foo</Text>
  )
}

// spec.js
// ... some setup ...
      driver
        .elementByAccessibilityId('foo')
          .click()

我正在……

      1) should be able to find 'Buttons' and click it


  0 passing (13s)
  1 failing

  1) Android find and click should be able to find 'Buttons' and click it:
     Error: [elementByAccessibilityId("foo")] Error response status: 7, , NoSuchElement - An element could not be located on the page using the given search parameters. Selenium error: An element could not be located on the page using the given search parameters.

我也试过设置: <Text accessible accessibilityLabel={ 'foo' }>foo</Text>

同样的 react ...

有什么想法吗?

最佳答案

我最终使用了这个解决方案:

<Text accessibilityLabel={ 'FOO' } testID={ 'FOO' }>some stuff here</Text>

然后在测试中:

driver
  .elementByAccessibilityId('FOO')

感谢@jonesdar 指出了这一点 here

关于android - React native + Appium,如何找到一个元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41469765/

相关文章:

java - Android - 广播接收器未被解雇

android - CSS:背景附件:固定在android中不起作用

android - 如何防止软键盘显示,或者至少在显示后将其驱逐?

react-native - 是否可以在 react-native 中镜像文本?

java - 你如何检查最后一行字符是否出现在字符串中

ios - Appium 检查器 - 应用程序不反射(reflect)在屏幕上

Android:无法使用 CustomAdapter 刷新 Listview

ios - react native 密码自动填充 ios 11

react-native - 如何淡入一个组件而另一个淡出?

java - AndroidDriver 类型未定义方法 complexFind(String)