加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

webview – 使用Appium for Automation访问React元素

发布时间:2020-12-15 20:54:26 所属栏目:百科 来源:网络整理
导读:我一直在使用Appium来测试混合Android应用程序,包括NATIVE和WEBVIEW上下文之间的频繁转换.这些Web视图是使用React Libraries开发的. To my understanding and correct me if I am wrong,07000 is that it creates a Virtual DOM using the real DOM and gene
我一直在使用Appium来测试混合Android应用程序,包括NATIVE和WEBVIEW上下文之间的频繁转换.这些Web视图是使用React Libraries开发的.

To my understanding and correct me if I am wrong,07000
is that it creates a Virtual DOM using the real DOM and generates a
dynamic class name corresponding to those in the javascript. The 07001 provides efficient way to differentiate the objects
using those auto generated class names.

我面临的问题是使用Appium我无法使用任何findElementsBy方法访问这些webview中的元素.在生成的每个新构建上,React都会更改类名,这个名称只是我们可以真正依赖的UIAutomator可见的参数.

  1. Is there a way so that I can refactor these auto-generated class names to some sensible names using the React library itself?

chrome inspect在我的应用程序中提供了webview的详细信息:

<div class="_32f8NoUfyUtNSxo3w4Ptbp" data-reactid=".0.1.$=13:0.0.0">…</div>
  1. Any ideas on how to access the actual DOM elements using Appium for this case?

信息:WebView.setWebContentsDebuggingEnabled(true)在应用程序代码中设置.

非常感谢这里的任何线索.

基于此链接: https://github.com/facebook/react-native/issues/7135

此问题的解决方法:在视图上使用accessible和accessibleLabel

accessiblity标签上的DOC:https://facebook.github.io/react-native/docs/accessibility.html#accessibilitylabel-ios-android

在我的本机组件上:

<TextInput accessible={true} accessibilityLabel={'Tap Me'}></TextInput>

在我的脚本测试:

mobileElement = find_Element(accessibilty_id,"Tap Me")
mobileElement.send_keys "hello world"

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读