Appium-Drivers-XCUITest(Xcode UI Test)

XCUITest:Xcode User Interface Testing

Appium’s primary support for automating iOS apps is via the XCUITest driver. (New to Appium? Read our introduction to Appium drivers). This driver leverages Apple’s XCUITest libraries under the hood in order to facilitate automation of your app . This access to XCUITest is mediated by the WebDriverAgent server. WebDriverAgent (also referred to as “WDA”) is a project managed by Facebook, to which the Appium core team contributes heavily. WDA is a WebDriver-compatible server that runs in the context of an iOS simulator or device and exposes the XCUITest API. Appium’s XCUITest driver manages WDA as a subprocess opaque to the Appium user, proxies commands to/from WDA, and provides a host of additional functionality (like simulator management and other methods, for example).

Appium对iOS应用程序自动化的主要支持是通过xguitest驱动程序.
这个驱动程序利用了Apple提供的XCUITest库,以促进应用程序的自动化。
对XCUITest的访问由WebDriverAgent服务器调节。
WebDriverAgent(也称为“WDA”)是由Facebook管理的项目,Appium核心团队做出重大贡献。WDA是一个与Web驱动兼容运行在iOS环境模拟器或设备环境中运行并公开XCUITest API。
Appium的XCUITest驱动程序将WDA作为对Appium用户不透明的子进程进行管理,代理WDA的命令,并提供大量附加功能(如,模拟器管理和其他方法)

Development of the XCUITest driver happens at the appium-xcuitest-driver repo.

XCUITest驱动程序在appium-xcuitest-driver repo中开发运行
Requirements and Support
需求和支持

In addition to Appium’s general requirements:
Appium一般要求除外

  • Apple’s XCUITest library is only available on iOS simulators and devices that are running iOS 9.3 or higher.
  • A Mac computer with macOS 10.11 or 10.12 is required.
  • Xcode 7 or higher is required.
  • The XCUITest driver was available in Appium starting with Appium 1.6.
  • For correct functioning of the driver, additional system libraries are required (see the Setup sections below).
Migrating from the UIAutomation Driver
从UIAutomation驱动程序迁移

If you are migrating to the XCUITest driver from Appium’s old UIAutomation-based driver, you may wish to consult this migration guide.

Usage
用法

The way to start a session using the XCUITest driver is to include the automationName capability in your new session request, with the value XCUITest. Of course, you must also include appropriate platformName, platformVersion, deviceName, and app capabilities, at a minimum.

使用XCUITest驱动程序在新的会话请求中包含`automationName`必须包含元素

The platformName should be iOS for iPhone or iPad. tvOS devices are available if the platformName is tvOS.

  • iOS
    json { "automationName": "XCUITest", "platformName": "iOS", "platformVersion": "12.2", "deviceName": "iPhone 8", ... }
  • tvOS
    json { "automationName": "XCUITest", "platformName": "tvOS", "platformVersion": "12.2", "deviceName": "Apple TV", ... }
Capabilities

The XCUITest driver supports a number of standard Appium capabilities, but has an additional set of capabilities that modulate the behavior of the driver. These can be found currently at the appium-xcuitest-driver README.

XCUITest驱动支持许多Appium标准功能,
但有一组额外的功能可调节驱动程序的行为

To automate Safari instead of your own application, leave the app capability empty and instead set the browserName capability to Safari.

要自动化Safari而不是自己的应用,
将`app`功能保留为空,
改为将`browserName`功能设置为`Safari`
Commands
命令

To see the various commands Appium supports, and specifically for information on how the commands map to behaviors for the XCUITest driver, see the API Reference.

Basic Setup
基本设置

(We recommend the use of Homebrew for installing system dependencies)

建议使用自制软件安装系统依赖项

Ensure that you have Appium’s general dependencies (e.g., Node & NPM) installed and configured.

确保已安装并配置了Appium的常规依赖项(例如,Node和NPM)

If you don’t need to automate real devices, you’re done! To automate an app on the simulator, the app capability should be set to an absolute path or url pointing to your .app or .app.zip file, built for the sim.

 如果你不需要自动化真正的设备,
 你就完了!要在模拟器上自动化应用程序,
 应将应用程序功能设置为指向.app或的绝对路径或url.
 应用程序.zip文件,为sim卡构建 
Real Device Setup

Automating a real device with XCUITest is considerably more complicated, due to Apple’s restrictions around running apps on real devices. Please refer to the XCUITest real device setup doc for instructions.

由于苹果对在真实设备上运行应用程序的限制,
用xguitest实现真实设备的自动化要复杂得多

Once set up, running a session on a real device is achieved by using the following desired capabilities:

设置完成后,
可通过使用以下所需功能在实际设备上运行会话:
  • app or bundleId - specifies the application (local path or url referencing your signed .ipa file) , or, if it is already installed, simply the bundle identifier of the app so that Appium can launch it.
`app``bundleId`-指定应用程序(引用已签名的.ipa文件的本地路径或url),
或者,如果已经安装了,
只需指定应用程序的绑定标识符,
以便Appium可以启动它
  • udid - the specific id of the device to test on. This can also be set to auto if there is only a single device, in which case Appium will determine the device id and use it.
`udid`-要测试的设备的特定id。
如果只有一个设备,这也可以设置为自动,
在这种情况下,Appium将确定设备id并使用它
Optional Setup
操作设置
  • Install idb for better handling of various iOS Simulator operations, such as: biometrics, geolocation setting and window focussing.
安装idb以更好地处理各种iOS模拟器操作,
例如:生物特征识别、地理位置设置和窗口聚焦
  • Read https://github.com/appium/appium-idb#installation to install necessary libraries (since Appium 1.14.0)
  • Install AppleSimulatorUtils to use the permissions capa
Files generated by test runs
测试运行生成的文件

Testing on iOS generates files that can sometimes get large. These include logs, temporary files, and derived data from Xcode runs. Generally the following locations are where they are found, should they need to be deleted:

在iOS上测试生成的文件有时会变大,
包括裹日志,临时文件,Xcode的运行数据,
通常如果需要删除,以下是可以找到他们的位置
$HOME/Library/Logs/CoreSimulator/*
$HOME/Library/Developer/Xcode/DerivedData/*
Configure keyboards
键盘配置 

Over Appium 1.14.0, Appium configures keyboard preferences by default to make test running more stable. You can change sone of them via settings API.

在Appium1.14.0以上版本,
Appium键盘配置默认首选项使测试运行更加稳定,
你可以更改API设置中的其中一个
  • Turn Auto-Correction in Keyboards off
关闭键盘中的自动更正
  • Turn Predictive in Keyboards off
关闭键盘
  • Mark keyboard tutorial as complete
将键盘标记为完成
  • (Only for Simulator) Toggle software keyboard on
打开软键盘(模拟器)
Accessibility preferences fine-tuning
辅助功能选项微调

In some cases, enabling of the below preferences helps to make some view elements accessible. Appium does not modify these settings automatically, since they could affect the way your application under test performs. Please change them manually if needed

有时候,启用以下首选项有助于访问某些视图元素。
Appium不会自动修改这些设置,
因为它们可能会影响被测应用程序的执行方式。
如果需要,请手动更改
  • Turn Spoken Content in Settings > Accessibility on
  • Turn Speak Selection in Settings > Accessibility on
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Aniona

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值