activities
latest
false
重要 :
请注意,此内容已使用机器翻译进行了部分本地化。 新发布内容的本地化可能需要 1-2 周的时间才能完成。
UiPath logo, featuring letters U and I in white

用户界面自动化活动

上次更新日期 2026年3月9日

本地 iOS 设备

设置本地 iOS 设备

要设置本地设备以使用“移动自动化”活动,您需要运行 Appium 的本地实例,并拥有自动化 iOS 设备的必要工具。

您可以自动化两种类型的本地 iOS 设备:

  • Physical - a physical iOS device that you can connect to your local machine, through a USB cable.
  • Emulator - an emulator for an iOS device that's stored locally.

最常用的 Appium 命令

下面的列表描述了在移动设备自动化(推荐用于Appium 2.0 )的上下文中设置 Appium 的最常用命令:

  • xcrun simctl list - 列出可用的设备、设备类型、运行时或设备对。
  • xcrun simctl list devices - 列出可用设备。
  • xcrun simctl list devicetypes - 列出设备类型。
  • xcrun simctl list runtimes - 列出运行时。
  • xcrun simctl list runtimes - 列出设备对。

应用程序存储

您需要将移动应用程序存储在运行 Appium 服务器的同一台计算机上,或者将 IPA 文件上传到 Appium 服务器可匿名访问的 URL(例如Blob 存储)。

无法从 Play 商店或 App Store 安装应用程序,除非您手动自动化这些应用程序以安装特定应用程序。

警告:

如果您的应用程序工件使用APP扩展程序,并且您想要将该应用程序上传到公共 URL,则需要创建一个名为Payload的文件夹,将APP放入其中,存档Payload文件夹并进行更改将扩展名改为IPA而不是ZIP。 此外,请确保针对目标架构(模拟器或物理设备)编译您尝试自动化的应用程序。

配置 iOS 物理设备

先决条件

  1. 安装 Xcode

  2. 打开终端并运行以下命令以安装 Homebrew:

    /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
    /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
    
    1. 运行以下命令,将 Homebrew 添加到PATH环境变量中:

      echo >> /Users/<username>/.zprofile
        echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> /Users/<username>/.zprofile
        eval "$(/opt/homebrew/bin/brew shellenv)"
      echo >> /Users/<username>/.zprofile
        echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> /Users/<username>/.zprofile
        eval "$(/opt/homebrew/bin/brew shellenv)"
      
  3. 运行以下命令以安装 NodeJS:

brew install node 4. 安装 Appium:

  • For Appium 1.0, run the following command: npm install -g appium. This automatically installed all drivers needed.
  • For Appium 2.0, run the following command: npm install -g appium@next.

Appium 2.0 comes without the drivers installed. Therefore, to install the needed drivers, also run the following command: appium driver install xcuitest.

警告:
  • We recommend using Appium 2.0 with Mobile Automation version 22.10 or higher.
  • 如果要在iOS 物理设备上测试移动端自动化,请安装Appium 2.0 。 1. 打开 Xcode 并允许其安装可能需要的任何其他组件。看到启动画面后,请关闭它。2. 使用以下命令启动 Appium 服务器: appium --port 8001 --default-capabilities "{\"appium:systemPort\":9001}" --relaxed-securitydocs image

配置本地 iOS 物理设备

  1. 将物理设备连接到 Mac。

  2. 解锁您的设备,如果弹出警示,请确保允许计算机访问它。

  3. 获取 Appium URL 并保存以备后用:

    • Go to System Settings, then the Network tab, and select the Wi-Fi network that the physical device is connected to.
    • 复制设备已连接的 Wi-Fi 网络的IP 地址。Appium URL 的格式为http://<ipaddress>:80018001是启动 Appium 的端口号)。docs image
  4. 从 XCode 获取已连接到计算机的物理 iOS 设备的 UDID。

    • Go to Window > Devices and Simulators > Devices.
    • 单击已连接到的 iOS 设备。
    • Copy the Identifier. This is the UDID, that you'll later add as an additional desired capability, when adding this iOS physical device to MDM.
  5. 在 Mac 上使用 XCode 构建WebDriverAgent

    • 使用以下路径导航到appium-webdriveragent文件夹: /Users/<username>/appium2/node_modules/appium-xcuitest-driver/node_modules/appium-webdriveragent ,然后打开xcodeproj文件。
    • Select WebDriverAgent, and open WebDriverAgentRunner, under the Targets section.
    • Switch to the Signing & Capabilities tab, select Automatically manage signing, and choose a user account from the Team dropdown.
    • Change the Bundle Identifier to a unique value.
    • 复制并保存此捆绑包标识符。您将使用它在 MDM 中添加应用程序(捆绑包 ID )。docs image
  6. Install the WebDriverAgent on your iOS physical device.

    • Select WebDriverAgentRunner in the WebDriverAgent navigation bar.
    • In XCode, go to Product, and click Test. On your connected iOS physical device, you'll see the WebDriverAgent installing.
  7. 使用“在移动设备管理器中添加 iOS 设备”过程,在移动设备管理器中添加已配置的本地实体 iOS 设备。

在移动设备管理器中添加本地 iOS 设备

  1. 从 Studio 打开移动设备管理器。

  2. 在左侧导航面板中,转到“测试用例”。

  3. 按如下方式配置您的设备:

    • 名称 - 在“设备”选项卡中输入用于标识设备的名称。

    • Appium URL - Enter the Appium URL, that you previously copied, using the following format: http://<ipaddress>:8001.

    • 平台 - 单击字段以从下拉列表中选择“Android”或“iOS”。

    • 设备名称 - 输入设备名称。

    • Additional Desired Capabilities - Add the following capabilities:

      名称
      automationNamexcuitest (此功能激活 Appium iOS 驱动程序)
      udidthe Identifier of the connected physical iOS device
  4. (可选)在“日志记录”选项卡中配置日志记录和视频录制详细信息。

  5. (可选)在“开发”选项卡中配置开发流程。

    • 关闭类似选项卡(默认情况下激活): 关闭与类似设备和应用程序运行连接的选项卡。
    • 等待页面更新(默认激活): 等待页面来源检索每个操作的屏幕截图。
  6. 单击“保存并关闭”以添加设备。

您的设备已添加到“设备”列表中。要添加本地设备,请参阅。如果您无法启动设备,请参阅故障排除:物理设备启动失败docs image

iOS 上的混合和网页自动化

如果您没有尝试自动化为生产而构建的应用程序,则默认情况下,混合自动化适用于 iOS 设备。在自动化生产应用程序时,WKWebView 托管的内容将不可自动化,但 SFSafariViewController 中托管的任何网页内容也可以在生产应用程序中实现自动化。有关更多信息,请参阅SFSafariViewController

此页面有帮助吗?

连接

需要帮助? 支持

想要了解详细内容? UiPath Academy

有问题? UiPath 论坛

保持更新