【问题标题】:React native + Appium, how to find an elementReact Native + Appium,如何找到一个元素
【发布时间】:2017-05-19 02:16:49
【问题描述】:

我正在尝试(太久......)让 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.

我也尝试过设置: &lt;Text accessible accessibilityLabel={ 'foo' }&gt;foo&lt;/Text&gt;

同样的反应...

有什么想法吗?

【问题讨论】:

  • 如果你有一个 React-Native slideOutMenu 并且你想点击其中一个 slideOutMenu 选项,你会怎么做。尤其是当滑出菜单仅覆盖其背后屏幕的 50% 时。 XCODE 的 AccessibilityInspector 可以看到滑出菜单,但 android 和 ios 的 appium 可访问性检查器甚至看不到滑出菜单。
  • 请参考此答案以找到 appium 的 RN 元素:stackoverflow.com/questions/33937898/…stackoverflow.com/questions/57460336/…

标签: android react-native appium


【解决方案1】:

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

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

然后在测试中:

driver
  .elementByAccessibilityId('FOO')

感谢@jonesdar 指出这一点here

【讨论】:

猜你喜欢
  • 2019-12-18
  • 2021-10-26
  • 2020-07-17
  • 2016-11-26
  • 2020-05-27
  • 2019-09-24
  • 2016-01-21
  • 2020-01-08
  • 1970-01-01
相关资源
最近更新 更多