如何在Xamarin.UiTest中使用自动化ID单击元素? [英] How to click the element using automation id in Xamarin.UiTest?

查看:57
本文介绍了如何在Xamarin.UiTest中使用自动化ID单击元素?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

该应用是使用Xamarin.forms开发的.我正在使用repl()检查该应用程序.使用树命令时,我可以看到以下输出

The app is developed using Xamarin.forms. I am examining the app using repl(). While using tree command i can see following output

>>> tree
[[object CalabashRootView] > DecorView]
  [LinearLayout > FrameLayout]
    [FitWindowsFrameLayout] id: "action_bar_root"
      [ContentFrameLayout > ... > PlatformRenderer] id: "content"
        [NavigationPageRenderer] id: "NoResourceEntry-9"
          [PageContainer] id: "NoResourceEntry-22"
            [PageRenderer > Platform_DefaultRenderer] id: "NoResourceEntry-17"
              [Platform_DefaultRenderer] label: "TermsAndConditions_main"
                [Platform_DefaultRenderer]
                  [Platform_DefaultRenderer]
                    [BoxRenderer] label: "TermsAndConditions_boxview"
                    [ExtendedLabelRenderer] label: "TermsAndConditions_lbTitle_Container"
                      [FormsTextView] id: "NoResourceEntry-18",  label: "TermsAndConditions_lbTitle",  text: "TERMS & CONDITIONS"
                    [BoxRenderer] label: "TermsAndConditions_boxview1"
                  [WebViewRenderer] label: "TermsAndConditions_webViewText_Container"
                    [WebView] id: "NoResourceEntry-19",  label: "TermsAndConditions_webViewText"
                [Platform_DefaultRenderer] label: "TermsAndConditions_btn"
                  [FrameRenderer > LabelRenderer] id: "NoResourceEntry-20"
                    [FormsTextView] id: "NoResourceEntry-21" text: "Accept"
  [View] id: "statusBarBackground"

所有自动化ID在树中均由 label 标签表示.如何使用 label 标签与元素进行交互?

All the automation Id is represented in the tree by label tag. How can i interact with the element with the label tag?

例如,我想单击标签为 TermsAndConditions_btn 的元素.我如何在Xamarin Uitest中做到这一点?

For example, i want to click the element with label TermsAndConditions_btn. How can i do this in Xamarin Uitest??

推荐答案

使用诸如 static readonly Func< AppQuery,AppQuery>MyLabel = c =>c.Marked("TermsAndConditions_btn"); ,然后调用 app.Tap(MyLabel).

这篇关于如何在Xamarin.UiTest中使用自动化ID单击元素?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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