簡體   English   中英

如何在Xamarin.UiTest中使用自動化ID單擊元素?

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

該應用程序是使用Xamarin.forms開發的。 我正在使用repl()檢查該應用程序。 使用樹命令時,我可以看到以下輸出

>>> 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標簽的元素進行交互?

例如,我想單擊帶有標簽TermsAndConditions_btn的元素。 我如何在Xamarin Uitest中做到這一點?

使用static readonly Func<AppQuery, AppQuery> MyLabel = c => c.Marked("TermsAndConditions_btn");獲取標簽static readonly Func<AppQuery, AppQuery> MyLabel = c => c.Marked("TermsAndConditions_btn"); 然后調用app.Tap(MyLabel)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM