访问使用Appium自动化元素做出反应 [英] Accessing React Elements using Appium for Automation

查看:371
本文介绍了访问使用Appium自动化元素做出反应的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直使用Appium测试一个混合的Andr​​oid应用程序,包括本地和环境的WebView之间的频繁转换。这些网页视图使用阵营库开发的。


  

要我的理解,并纠正我,如果我错了,的如何反应工程
  是它创建使用DOM真正的虚拟DOM并产生
  相应于在JavaScript动态类名。该 DIFF
  算法
提供有效的方式来区分对象
  使用这些自动生成的类名。



我现在面临的问题是,使用Appium我无法从使用任何 findElementsBy 法的这些网页视图访问的元素。类名被唯一参数可见的UIAutomator上,我们可以真正依靠由上做出反应生成的每个新版本的变化。


  

      
  1. 有没有办法让我可以使用阵营库本身重构这些自动生成的类名来一些明智的名字?

  2.   

href=\"http://chrome://inspect/#devices\">铬检查的

 < D​​IV CLASS =_ 32f8NoUfyUtNSxo3w4Ptbp数据reactid =$ 0.1 = 13:0.0.0> ...< / DIV>


  <醇开始=2>
  
  • 在如何访问使用Appium实际的DOM元素这种情况下任何想法?

  •   

    信息: WebView.setWebContentsDebuggingEnabled(真)设置在应用程序code

    请问AP preciate任何线索在这里。


    解决方案

    根据此链接: https://github.com/facebook/react-native/issues/7135

    有关此问题的解决方法:使用您的看法都可以访问和accessibleLabel

    可访问性标签上DOC:<一href=\"https://facebook.github.io/react-native/docs/accessibility.html#accessibilitylabel-ios-android\" rel=\"nofollow\">https://facebook.github.io/react-native/docs/accessibility.html#accessibilitylabel-ios-android

    在我的反应机组件:

     &LT;的TextInput访问= {TRUE} accessibilityLabel = {'点击我'}&GT;&LT; /&的TextInput GT;

    在我的脚本测试:

      mobileElement = find_Element(accessibilty_id,点击我)
    mobileElement.send_keys的hello world

    I have been using Appium to test an hybrid android application including frequent transition between NATIVE and WEBVIEW context. These Webviews are developed using React Libraries.

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


    The problem I am facing is that using Appium I am not able to access the elements from these webview using any of the findElementsBy method. The class name being only parameter visible to the UIAutomator on which we could really rely on is changed by React on every new build generated.

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

    The chrome inspect provides the details of the webview in my application as :

    <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?

    Info : WebView.setWebContentsDebuggingEnabled(true) is set in the app code.

    Would appreciate any leads here as well.

    解决方案

    Based on this link : https://github.com/facebook/react-native/issues/7135

    The workaround for this problem : use both accessible and accessibleLabel on your views

    DOC on accessiblity label: https://facebook.github.io/react-native/docs/accessibility.html#accessibilitylabel-ios-android

    On my react native component :

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

    On my script Test :

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

    这篇关于访问使用Appium自动化元素做出反应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆