【问题标题】:How to set automation id for elements of xamarin.ios app for TestAutomation?如何为 TestAutomation 的 xamarin.ios 应用程序的元素设置自动化 ID?
【发布时间】:2019-07-18 07:15:07
【问题描述】:

我想使用 Xamarin.UITest 为 xamarin ios 应用程序设置自动化测试,有一种方法可以为 Xamarin.Forms 项目设置自动化 ID,但找不到为 iOS 应用程序设置的方法。

我已经安装了两个 nuget - Xamarin.UITest -NUnit

并在测试类文件中设置代码

var config = ConfigureApp
                .iOS
                .InstalledApp("package.identifier")
                .EnableLocalScreenshots();

【问题讨论】:

    标签: xamarin.ios visual-studio-app-center


    【解决方案1】:

    您可以对原生 iOS 元素使用“AccessibilityIdentifier”属性。我已经测试过了,它在我的最后工作。

    【讨论】:

    • 添加AccessibilityIdentifier 对象的代码示例以帮助他们了解如何使用它,总不会有什么坏处。
    • 在故事板文件中选择元素时,可以在属性面板上找到该属性
    【解决方案2】:

    您可以为每个表单元素设置自动化 ID,方法是进入 MainPage.xaml 并为 . 例如

       <StackLayout>
            <!-- Place new controls here -->
            <Label Text="Welcome to Xamarin.Forms!" 
               HorizontalOptions="Center"
               AutomationId="Label1"
               VerticalOptions="CenterAndExpand" />
        </StackLayout>
    

    【讨论】:

    • 但我正在寻找 Xamarin.iOS [native] 解决方案。 @ssheode
    猜你喜欢
    • 2019-08-24
    • 2014-01-14
    • 2013-05-08
    • 2021-12-25
    • 1970-01-01
    • 1970-01-01
    • 2013-10-06
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多