How to click the element using automation id in Xamarin.UiTest?

不问归期 提交于 2021-02-05 09:47:43

问题


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"

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

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


回答1:


Get the label with something like static readonly Func<AppQuery, AppQuery> MyLabel = c => c.Marked("TermsAndConditions_btn"); and then call app.Tap(MyLabel).



来源:https://stackoverflow.com/questions/54107692/how-to-click-the-element-using-automation-id-in-xamarin-uitest

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!