

本文属于机器翻译版本。若本译文内容与英语原文存在差异，则一律以英文原文为准。

# 在 Device Farm 中自动运行 Appium 测试
<a name="test-types-appium"></a><a name="test-types-ios-appium-java-testng"></a><a name="test-types-ios-appium-java-junit"></a><a name="test-types-ios-appium-python"></a><a name="test-types-ios-appium-ruby"></a><a name="test-types-ios-appium-node"></a><a name="test-types-android-appium-java-testng"></a><a name="test-types-android-appium-java-junit"></a><a name="test-types-android-appium-python"></a><a name="test-types-android-appium-ruby"></a><a name="test-types-android-appium-node"></a><a name="test-types-web-app-appium-java-testng"></a><a name="test-types-web-app-appium-java-junit"></a><a name="test-types-web-app-appium-python"></a><a name="test-types-web-app-appium-ruby"></a><a name="test-types-web-app-appium-node"></a>

**注意**  
本页介绍了在 Device Farm 的托管**服务器端**执行环境中运行 Appium 测试。要在远程访问会话期间从本地**客户端**环境运行 Appium 测试，请参阅客户[端](appium-endpoint.md) Appium 测试。

本节介绍如何配置、打包和上传您的 Appium 测试，以便在 Device Farm 的托管服务器端环境中运行。Appium 是一种开源工具，用于自动执行本机和移动合应用程序。有关更多信息，请参阅 Appium 网站上的 [Appium 简介](http://appium.io/docs/en/latest/intro)。

有关示例应用程序和工作测试链接，请参阅适用于 [Android 的 Device Farm 示例应用程序和适用于](https://github.com/aws-samples/aws-device-farm-sample-app-for-android) [iOS 的 Device Farm 示例应用程序](https://github.com/aws-samples/aws-device-farm-sample-app-for-ios) GitHub。

有关在 Device Farm 中进行测试以及服务器端工作原理的更多信息，请参阅[AWS Device Farm 中的测试框架和内置测试](test-types.md)。

## 选择 Appium 版本
<a name="w2aac24c15c41"></a>

**注意**  
 对特定 Appium 版本、Appium 驱动程序或编程的支持 SDKs 将取决于为测试运行选择的设备和测试主机。

 Device Farm 测试主机预装了 Appium，以便在更简单的用例中更快地设置测试。但是，如果需要，使用测试规范文件可以安装不同版本的 Appium。

### 场景 1：预配置的 Appium 版本
<a name="w2aac24c15c41b7b1"></a>

 根据测试主机，Device Farm 预先配置了不同的 Appium 服务器版本。主机附带的工具可使用设备平台的默认驱动程序启用预配置版本（UiAutomator2 个适用于 Android，iOS 有 2 个）。 XCUITest 

```
phases:
  install:
    commands:
      - export APPIUM_VERSION=2
      - devicefarm-cli use appium $APPIUM_VERSION
```

 要查看支持的软件列表，请参阅中的主题[自定义测试环境中支持的软件](custom-test-environments-hosts-software.md)。

### 场景 2：自定义 Appium 版本
<a name="w2aac24c15c41b7b3"></a>

 要选择自定义版本的 Appium，请使用`npm`命令进行安装。以下示例显示如何安装最新版本的 Appium 2。

```
phases:
  install:
    commands:
      - export APPIUM_VERSION=2
      - npm install -g appium@$APPIUM_VERSION
```

### 场景 3：旧版 iOS 主机上的 Appium
<a name="w2aac24c15c41b7b5"></a>

 在上[旧版 iOS 测试主机](custom-test-environments-hosts-ios.md#legacy-ios-host)，你可以使用选择特定的 Appium 版本。`avm`例如，要使用`avm`命令将 Appium 服务器版本设置为`2.1.2`，请将这些命令添加到您的测试规范 YAML 文件中。

```
phases:
  install:
    commands:
      - export APPIUM_VERSION=2.1.2
      - avm $APPIUM_VERSION
```

## 为 iOS 测试选择 WebDriverAgent 版本
<a name="test-types-appium-select-wda"></a>

 要在 iOS 设备上运行 Appium 测试，需要使用。 WebDriverAgent 此应用程序必须经过签名才能安装在 iOS 设备上。Device Farm 提供了在自定义测试环境运行期间可用的预签名版本。 WebDriverAgent 

 以下代码片段可用于在测试规范文件中的 De WebDriverAgent vice Farm 上选择与您的 XCTest UI 驱动程序版本兼容的版本。

```
phases:
  pre_test:
    commands:
      - |-
        APPIUM_DRIVER_VERSION=$(appium driver list --installed --json | jq -r ".xcuitest.version" | cut -d "." -f 1);
        CORRESPONDING_APPIUM_WDA=$(env | grep "DEVICEFARM_APPIUM_WDA_DERIVED_DATA_PATH_V${APPIUM_DRIVER_VERSION}")
        if [[ ! -z "$APPIUM_DRIVER_VERSION" ]] && [[ ! -z "$CORRESPONDING_APPIUM_WDA" ]]; then
          echo "Using Device Farm's prebuilt WDA version ${APPIUM_DRIVER_VERSION}.x, which corresponds with your driver";
          DEVICEFARM_APPIUM_WDA_DERIVED_DATA_PATH=$(echo $CORRESPONDING_APPIUM_WDA | cut -d "=" -f2)
        else
          LATEST_SUPPORTED_WDA_VERSION=$(env | grep "DEVICEFARM_APPIUM_WDA_DERIVED_DATA_PATH_V" | sort -V -r | head -n 1)
          echo "Unknown driver version $APPIUM_DRIVER_VERSION; falling back to the Device Farm default version of $LATEST_SUPPORTED_WDA_VERSION";
          DEVICEFARM_APPIUM_WDA_DERIVED_DATA_PATH=$(echo $LATEST_SUPPORTED_WDA_VERSION | cut -d "=" -f2)
        fi;
```

 [有关更多信息 WebDriverAgent，请参阅 Appium 的文档。](https://appium.github.io/appium-xcuitest-driver/9.10/guides/run-prebuilt-wda/)

# 将 Appium 测试与 Device Farm 集成
<a name="test-types-appium-integrate"></a>

按照以下说明将 Appium 测试与 AWS Device Farm 集成。有关在 Device Farm 中使用 Appium 测试的更多信息，请参阅 [在 Device Farm 中自动运行 Appium 测试将 Appium 测试与 Device Farm 集成](test-types-appium.md)。

## 配置您的 Appium 测试程序包
<a name="test-types-appium-prepare"></a>

使用下面的说明来配置您的测试程序包。

------
#### [ Java (JUnit) ]

1. 修改 `pom.xml` 以将包设置为 JAR 文件：

   ```
   <groupId>com.acme</groupId>
   <artifactId>acme-myApp-appium</artifactId>
   <version>1.0-SNAPSHOT</version>
   <packaging>jar</packaging>
   ```

1. 修改 `pom.xml` 以使用 `maven-jar-plugin` 将测试构建到 JAR 文件中。

   以下插件将您的测试源代码 (`src/test` 目录中的任何内容) 构建到 JAR 文件中：

   ```
   <plugin>
     <groupId>org.apache.maven.plugins</groupId>
     <artifactId>maven-jar-plugin</artifactId>
     <version>2.6</version>
     <executions>
       <execution>
         <goals>
           <goal>test-jar</goal>
         </goals>
       </execution>
     </executions>
   </plugin>
   ```

1. 修改 `pom.xml` 以使用 `maven-dependency-plugin` 将依赖项构建为 JAR 文件。

   以下插件会将您的依赖项复制到 `dependency-jars` 目录：

   ```
   <plugin>
     <groupId>org.apache.maven.plugins</groupId>
     <artifactId>maven-dependency-plugin</artifactId>
     <version>2.10</version>
     <executions>
       <execution>
         <id>copy-dependencies</id>
         <phase>package</phase>
         <goals>
           <goal>copy-dependencies</goal>
         </goals>
         <configuration>
           <outputDirectory>${project.build.directory}/dependency-jars/</outputDirectory>
         </configuration>
       </execution>
     </executions>
   </plugin>
   ```

1. 将以下 XML 组件保存到 `src/main/assembly/zip.xml`。

   以下 XML 是一个组件定义，配置后可指示 Maven 构建一个 .zip 文件，其中包含构建输出目录和 `dependency-jars` 目录的根中的所有内容：

   ```
   <assembly
       xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
     <id>zip</id>
     <formats>
       <format>zip</format>
     </formats>
     <includeBaseDirectory>false</includeBaseDirectory>
     <fileSets>
       <fileSet>
         <directory>${project.build.directory}</directory>
         <outputDirectory>./</outputDirectory>
         <includes>
           <include>*.jar</include>
         </includes>
       </fileSet>
       <fileSet>
         <directory>${project.build.directory}</directory>
         <outputDirectory>./</outputDirectory>
         <includes>
           <include>/dependency-jars/</include>
         </includes>
       </fileSet>
     </fileSets>
   </assembly>
   ```

1. 修改 `pom.xml` 以使用 `maven-assembly-plugin` 将测试和所有依赖项打包到一个 .zip 文件。

   每当 **mvn package** 运行时，以下插件便使用前面的组件在构建输出目录中创建一个名为 `zip-with-dependencies` 的 .zip 文件：

   ```
   <plugin>
     <artifactId>maven-assembly-plugin</artifactId>
     <version>2.5.4</version>
     <executions>
       <execution>
         <phase>package</phase>
         <goals>
           <goal>single</goal>
         </goals>
         <configuration>
           <finalName>zip-with-dependencies</finalName>
           <appendAssemblyId>false</appendAssemblyId>
           <descriptors>
             <descriptor>src/main/assembly/zip.xml</descriptor>
           </descriptors>
         </configuration>
       </execution>
     </executions>
   </plugin>
   ```

**注意**  
如果您收到表明 1.3 不支持注释的错误消息，请将以下内容添加到 `pom.xml`：  

```
<plugin>
  <artifactId>maven-compiler-plugin</artifactId>
  <configuration>
    <source>1.7</source>
    <target>1.7</target>
  </configuration>
</plugin>
```

------
#### [ Java (TestNG) ]

1. 修改 `pom.xml` 以将包设置为 JAR 文件：

   ```
   <groupId>com.acme</groupId>
   <artifactId>acme-myApp-appium</artifactId>
   <version>1.0-SNAPSHOT</version>
   <packaging>jar</packaging>
   ```

1. 修改 `pom.xml` 以使用 `maven-jar-plugin` 将测试构建到 JAR 文件中。

   以下插件将您的测试源代码 (`src/test` 目录中的任何内容) 构建到 JAR 文件中：

   ```
   <plugin>
     <groupId>org.apache.maven.plugins</groupId>
     <artifactId>maven-jar-plugin</artifactId>
     <version>2.6</version>
     <executions>
       <execution>
         <goals>
           <goal>test-jar</goal>
         </goals>
       </execution>
     </executions>
   </plugin>
   ```

1. 修改 `pom.xml` 以使用 `maven-dependency-plugin` 将依赖项构建为 JAR 文件。

   以下插件会将您的依赖项复制到 `dependency-jars` 目录：

   ```
   <plugin>
     <groupId>org.apache.maven.plugins</groupId>
     <artifactId>maven-dependency-plugin</artifactId>
     <version>2.10</version>
     <executions>
       <execution>
         <id>copy-dependencies</id>
         <phase>package</phase>
         <goals>
           <goal>copy-dependencies</goal>
         </goals>
         <configuration>
           <outputDirectory>${project.build.directory}/dependency-jars/</outputDirectory>
         </configuration>
       </execution>
     </executions>
   </plugin>
   ```

1. 将以下 XML 组件保存到 `src/main/assembly/zip.xml`。

   以下 XML 是一个组件定义，配置后可指示 Maven 构建一个 .zip 文件，其中包含构建输出目录和 `dependency-jars` 目录的根中的所有内容：

   ```
   <assembly
       xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
     <id>zip</id>
     <formats>
       <format>zip</format>
     </formats>
     <includeBaseDirectory>false</includeBaseDirectory>
     <fileSets>
       <fileSet>
         <directory>${project.build.directory}</directory>
         <outputDirectory>./</outputDirectory>
         <includes>
           <include>*.jar</include>
         </includes>
       </fileSet>
       <fileSet>
         <directory>${project.build.directory}</directory>
         <outputDirectory>./</outputDirectory>
         <includes>
           <include>/dependency-jars/</include>
         </includes>
       </fileSet>
     </fileSets>
   </assembly>
   ```

1. 修改 `pom.xml` 以使用 `maven-assembly-plugin` 将测试和所有依赖项打包到一个 .zip 文件。

   每当 **mvn package** 运行时，以下插件便使用前面的组件在构建输出目录中创建一个名为 `zip-with-dependencies` 的 .zip 文件：

   ```
   <plugin>
     <artifactId>maven-assembly-plugin</artifactId>
     <version>2.5.4</version>
     <executions>
       <execution>
         <phase>package</phase>
         <goals>
           <goal>single</goal>
         </goals>
         <configuration>
           <finalName>zip-with-dependencies</finalName>
           <appendAssemblyId>false</appendAssemblyId>
           <descriptors>
             <descriptor>src/main/assembly/zip.xml</descriptor>
           </descriptors>
         </configuration>
       </execution>
     </executions>
   </plugin>
   ```

**注意**  
如果您收到表明 1.3 不支持注释的错误消息，请将以下内容添加到 `pom.xml`：  

```
<plugin>
  <artifactId>maven-compiler-plugin</artifactId>
  <configuration>
    <source>1.7</source>
    <target>1.7</target>
  </configuration>
</plugin>
```

------
#### [ Node.JS ]

要打包 Appium Node.js 测试并将其上传到 Device Farm，您必须在本地计算机上安装以下内容：
+ [节点版本管理器 (nvm)](https://github.com/nvm-sh/nvm) 

  在开发和打包测试时使用此工具，以便测试程序包中不包含不必要的依赖项。
+ Node.js
+ npm-bundle（全局安装）

1. 验证 nvm 是否存在

   ```
   command -v nvm
   ```

   您应在输出中看到 `nvm`。

   有关更多信息，请参阅 [nvm](https://github.com/nvm-sh/nvm) on。 GitHub

1. 运行此命令以安装 Node.js：

   ```
   nvm install node
   ```

   您可以指定 Node.js 的特定版本：

   ```
   nvm install 11.4.0
   ```

1. 验证是否正在使用正确版本的 Node：

   ```
   node -v
   ```

1. 全局安装 **npm-bundle**：

   ```
   npm install -g npm-bundle
   ```

------
#### [ Python ]

1. 我们强烈建议您设置 [Python virtualenv](https://pypi.python.org/pypi/virtualenv) 用于开发和打包测试，以便不必要的依赖项不包含在您的应用程序包中。

   ```
   $ virtualenv workspace
   $ cd workspace
   $ source bin/activate
   ```
**提示**  
请勿使用 `--system-site-packages` 选项创建 Python virtualenv，因为它会从全局 site-packages 目录中继承程序包。这可能导致您将测试不需要的依赖项包含在您的虚拟环境中。
您还应验证您的测试不使用依赖本机库的依赖项，因为这些本机库可能不位于运行这些测试的实例上。

1. 在您的虚拟环境中安装 **py.test**。

   ```
   $ pip install pytest
   ```

1. 在您的虚拟环境中安装 Appium Python 客户端。

   ```
   $ pip install Appium-Python-Client
   ```

1. 除非您在自定义模式下指定其他路径，否则 Device Farm 会认为您的测试存储在 `tests/` 中。您可以使用 `find` 显示文件夹中的所有文件：

   ```
   $ find tests/
   ```

   确认这些文件包含您要在 Device Farm 上运行的测试套件

   ```
   tests/
   tests/my-first-tests.py
   tests/my-second-tests/py
   ```

1. 从虚拟环境工作空间文件夹运行此命令，以显示测试列表而不运行它们。

   ```
   $ py.test --collect-only tests/
   ```

   确认输出显示您要在 Device Farm 上运行的测试。

1. 清除 tests/ 文件夹下的所有缓存文件：

   ```
   $ find . -name '__pycache__' -type d -exec rm -r {} +
   $ find . -name '*.pyc' -exec rm -f {} +
   $ find . -name '*.pyo' -exec rm -f {} +
   $ find . -name '*~' -exec rm -f {} +
   ```

1. 在您的工作空间中运行以下命令以生成 requirements.txt 文件：

   ```
   $ pip freeze > requirements.txt
   ```

------
#### [ Ruby ]

要打包 Appium Ruby 测试并将其上传到 Device Farm，您必须在本地计算机上安装以下内容：
+ [Ruby 版本管理器 (RVM)](https://rvm.io/rvm/install)

  在开发和打包测试时使用此命令行工具，以便测试程序包中不包含不必要的依赖项。
+ Ruby
+ Bundler（此 gem 通常与 Ruby 一起安装。）

1. 安装所需的密钥、RVM 和 Ruby。有关说明，请参阅 RVM 网站上的[安装 RVM](https://rvm.io/rvm/install)。

   安装完成后，通过注销然后再次登录来重新加载终端。
**注意**  
RVM 仅作为 bash shell 的函数加载。

1. 验证 **rvm** 是否已正确安装。

   ```
   command -v rvm
   ```

   您应在输出中看到 `rvm`。

1. 如果要安装特定版本的 Ruby，例如*2.5.3*，请运行以下命令：

   ```
   rvm install ruby 2.5.3 --autolibs=0
   ```

   验证您是否在使用所请求的 Ruby 版本：

   ```
   ruby -v
   ```

1. 配置捆绑器以编译适用于所需测试平台的软件包：

   ```
   bundle config specific_platform true
   ```

1. 更新您的 .lock 文件以添加运行测试所需的平台。
   + 如果您正在编译要在 Android 设备上运行的测试，请运行以下命令将 Gemfile 配置为使用 Android 测试主机的依赖项：

     ```
     bundle lock --add-platform x86_64-linux
     ```
   + 如果您正在编译要在 iOS 设备上运行的测试，请运行以下命令将 Gemfile 配置为使用 iOS 测试主机的依赖项：

     ```
     bundle lock --add-platform x86_64-darwin
     ```

1. 默认情况下，通常会安装 **bundler** gem。如果未安装，请安装它：

   ```
   gem install bundler -v 2.3.26
   ```

------

## 创建压缩程序包文件
<a name="test-types-appium-create-a-zip"></a>

**警告**  
在 Device Farm 中，压缩后的测试包中文件的文件夹结构很重要，一些归档工具会隐式更改 ZIP 文件的结构。我们建议您使用下面指定的命令行实用程序，而不是使用本地桌面文件管理器中内置的归档实用程序（例如 Finder 或 Windows Explorer）。

现在，将测试打包以用于 Device Farm。

------
#### [ Java (JUnit) ]

构建和打包测试：

```
$ mvn clean package -DskipTests=true
```

最后将创建文件 `zip-with-dependencies.zip`。这是您的测试程序包。

------
#### [ Java (TestNG) ]

构建和打包测试：

```
$ mvn clean package -DskipTests=true
```

最后将创建文件 `zip-with-dependencies.zip`。这是您的测试程序包。

------
#### [ Node.JS ]

1. 查看您的项目。

   确保您位于项目的根目录中。您可以在根目录中看到 `package.json`。

1. 运行此命令来安装您的本地依赖项。

   ```
   npm install
   ```

   此命令还会在当前目录中创建一个 `node_modules` 文件夹。
**注意**  
此时，您应该能够在本地运行您的测试。

1. 运行此命令以将当前文件夹中的文件打包为 \$1.tgz 文件。使用 `package.json` 文件中的 `name` 属性命名此文件。

   ```
   npm-bundle
   ```

   此 tarball (.tgz) 文件包含您的所有代码和依赖项。

1. 运行此命令将上一步中生成的 tarball（\$1.tgz 文件）捆绑到单个压缩存档中：

   ```
   zip -r MyTests.zip *.tgz
   ```

   这是您在以下过程中上传到 Device Farm 的 `MyTests.zip` 文件。

------
#### [ Python ]

Python 2  
使用 pip 生成所需的 Python 程序包的存档（称为“wheelhouse”）：  

```
$ pip wheel --wheel-dir wheelhouse -r requirements.txt
```
将 wheelhouse、测试和 pip 要求打包到 zip 存档中，以用于 Device Farm：  

```
$ zip -r test_bundle.zip tests/ wheelhouse/ requirements.txt
```

Python 3  
将测试和 pip 要求打包到 zip 文件中：  

```
$ zip -r test_bundle.zip tests/ requirements.txt
```

------
#### [ Ruby ]

1. 运行此命令以创建虚拟 Ruby 环境：

   ```
   # myGemset is the name of your virtual Ruby environment
   rvm gemset create myGemset
   ```

1. 运行此命令以使用您刚刚创建的环境：

   ```
   rvm gemset use myGemset
   ```

1. 请查看您的源代码。

   确保您位于项目的根目录中。您可以在根目录中看到 `Gemfile`。

1. 运行此命令以从 `Gemfile` 安装您的本地依赖项和所有 Gem。

   ```
   bundle install
   ```
**注意**  
此时，您应该能够在本地运行您的测试。使用此命令在本地运行测试：  

   ```
   bundle exec $test_command
   ```

1. 将您的 Gem 打包到 `vendor/cache` 文件夹中。

   ```
   # This will copy all the .gem files needed to run your tests into the vendor/cache directory
   bundle package --all-platforms
   ```

1. 运行以下命令将源代码以及所有依赖项捆绑到单个压缩存档中：

   ```
   zip -r MyTests.zip Gemfile vendor/ $(any other source code directory files)
   ```

   这是您在以下过程中上传到 Device Farm 的 `MyTests.zip` 文件。

------

## 将您的测试程序包上传到 Device Farm
<a name="test-types-appium-upload"></a>

您可以使用 Device Farm 控制台上传测试。

1. 登录 DeviceFarm 控制台，网址为 [https://console.aws.amazon.com/devicef](https://console.aws.amazon.com/devicefarm) arm。

1. 在 Device Farm 导航面板上，选择**移动设备测试**，然后选择**项目**。

1. 如果您是新用户，请选择**新建项目**，输入项目的名称，然后选择**提交**。

   如果您已有项目，可以选择该项目以将您的测试上传到该项目。

1. 打开您的项目，然后选择**创建运行**。

1. 在**运行设置**下，为您的测试指定一个适当的名称。这可能包含空格或标点符号的任意组合。

1.   
适用于本机 Android 和 iOS 测试  
如果您测试的是 Android（.apk）应用程序，请在**运行设置**下选择 **Android 应用程序**；如果您测试的是 iOS（.ipa）应用程序，请选择 **iOS 应用程序**。然后，在**选择应用程序**下，选择**上传自己的应用程序**以上传您应用程序的可分发程序包。  
 该文件必须是 Android `.apk` 或 iOS `.ipa`。iOS 应用程序必须是针对真实设备而不是模拟器构建的。  
适用于移动 Web 应用程序测试  
在**运行设置**下，选择 **Web 应用程序**。

1. 在**配置测试**下的**选择测试框架**部分中，选择测试使用的 Appium 框架，然后**上传自己的测试程序包**。

1. 浏览到并选择包含您的测试的 .zip 文件。该 .zip 文件必须遵循[配置您的 Appium 测试程序包](#test-types-appium-prepare)中所述的格式。

1. 按照说明来选择设备并开始运行。有关更多信息，请参阅 [在 Device Farm 中创建测试运行](how-to-create-test-run.md)。

**注意**  
Device Farm 不会修改 Appium 测试。

## 拍摄测试的屏幕截图（可选）
<a name="test-types-appium-screenshots"></a>

您可以拍摄屏幕截图作为测试的一部分。

Device Farm 会将 `DEVICEFARM_SCREENSHOT_PATH` 属性设置为本地文件系统中的一个完全限定路径（这是 Device Farm 希望 Appium 屏幕截图保存到的路径)。存储屏幕截图的特定于测试的目录在运行时定义。系统会自动将这些屏幕截图提取到您的 Device Farm 报告中。要查看屏幕截图，请在 Device Farm 控制台中选择 **Screenshots (屏幕截图)** 部分。

 有关在 Appium 测试中拍摄屏幕截图的更多信息，请参阅 Appium API 文档中的[拍摄屏幕截图](http://appium.io/docs/en/commands/session/screenshot/)。