如何将Calabash添加到Xamarin.UITest的React Native iOS [英] How to Add Calabash to React Native iOS for Xamarin.UITest
问题描述
如何将Calabash框架添加到React Native内置的iOS应用中?
How can I add the Calabash Framework to an iOS app built in React Native?
我们正在将iOS应用程序的代码库从Swift迁移到React Native,并且我拥有使用Xamarin.UITest用C#构建的现有UITests套件.
We are moving the codebase of our iOS app from Swift to React Native, and I have an existing suite of UITests built in C# using Xamarin.UITest.
我想继续将我的Xamarin.UITest套件用于React Native iOS应用程序,但是我知道Xamarin.UITest需要在应用程序的源代码中链接Calabash框架.
I'd like to continue using my Xamarin.UITest suite for the React Native iOS app, but I know that Xamarin.UITest requires the Calabash framework to be linked in the app's source code.
Xamarin具有文档关于如何为Xcode内置的iOS应用程序链接Calabash的信息,但是我找不到任何有关如何为React Native内置的iOS应用程序链接Calabash的文档.
Xamarin has documentation on how to link Calabash for an iOS app built in Xcode, but I cannot find any documentation on how to link Calabash for an iOS app built in React Native.
是否有类似的文档显示如何将Calabash链接到React Native iOS应用?
Is there any similar documentation that shows how to link Calabash to a React Native iOS app?
推荐答案
在React Native中内置的iOS应用会自动创建一个.xcodeproj
文件,并依赖Xcode项目进行构建/部署.这是新初始化的React Native Project的图像.
iOS apps built in React Native automatically create an .xcodeproj
file and rely on an Xcode project for build/deploy. Here is an image of a newly initialized React Native Project.
Xamarin.UITest要求将Calabash框架链接到iOS应用.由于React Native iOS应用程序依赖于.xcodeproj
,因此我们可以按照与用Swift/ObjC编写应用程序相同的步骤注入Calabash.要完成此操作,请遵循以下教程:链接调试配置中的葫芦.
Xamarin.UITest requires that the Calabash Framework be linked to the iOS app. Because React Native iOS apps rely on an .xcodeproj
, we can inject Calabash following the same steps as if the app was written in Swift/ObjC. To accomplish, follow this Tutorial: Link Calabash in Debug config.
在JavaScript源代码中,使用accessibilityLabel
属性将唯一标识符添加到每个屏幕元素. 在此示例中,我们已将TextInput标识为"TextInputAccessibilityId".
In the JavaScript source code, add a unique identifier to each on-screen element using the accessibilityLabel
property. In this example we've identified our TextInput as "TextInputAccessibilityId".
在Xamarin.UITest中,我们现在可以创建一个字段readonly Query TextInput
,并使用相同的属性对其进行初始化: .现在,我们可以与我们屏幕上的该元素进行交互Xamarin.UITest !
In the Xamarin.UITest, we can now create a field, readonly Query TextInput
, and initialize it using the same property: TextInput = x => x.Marked("TextInputAccessibilityId");
. Now we can interact with this on-screen element in our Xamarin.UITest!
All tests were verified in Xamarin Test Cloud, and the results are viewable here.
这篇关于如何将Calabash添加到Xamarin.UITest的React Native iOS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!