【发布时间】:2015-12-10 21:55:55
【问题描述】:
我一直在尝试针对使用 Xamarin Forms 创建的 Android 和 iOS 应用运行测试记录器。当我单击测试记录器中的控件时,我没有看到放置在生成的 C# 文件中的 Id,只有类类型。
我决定从等式中删除测试记录器,并尝试让基本的 UI 测试针对 Xamarin Forms Android 应用运行。
我从这里下载了一个演示应用程序:
https://developer.xamarin.com/samples/xamarin-forms/UsingUITest/
它应该有所有的东西来正确处理 UITest,包括 StyleIds 和 MainActivity 中用于将 StyleIds 映射到 ContentDescriptions 的代码。
我在 REPL 终端会话中运行 tree 来检查屏幕层次结构,它似乎没有显示应该拥有它们的控件的 id。
>>> tree
[[object CalabashRootView] > PhoneWindow$DecorView]
[ActionBarOverlayLayout] id: "decor_content_parent"
[FrameLayout > ... > Platform_DefaultRenderer] id: "content"
[ButtonRenderer]
[Button] label: "MyButton", text: "Click me"
[LabelRenderer]
[FormsTextView] label: "MyLabel", text: "Hello, Xamarin.Forms!"
[View] id: "navigationBarBackground"
[View] id: "statusBarBackground"
>>>
有什么想法吗?
【问题讨论】:
-
StyleId 在该输出中...看到“MyButton”和“MyLabel”了吗?这些是 StyleId 值。您是否尝试过运行选择器以查看是否可以从中进行选择?
-
感谢 Dylan - 我可以在输出中看到 MyButton 的 StyleId 已转换为 MyButton 的标签。进一步挖掘后,我看到 StyleId 被转换为 iOS 的 AccessibilityIdentifier 和 Android 的 ContentDescription,我猜这些都是作为标签出现的。我的问题是,虽然我可以通过编程方式访问这些,但当我单击控件时,TestRecorder 不会生成 .Marked()。
标签: xamarin xamarin.forms uitest