mirror of
https://github.com/appium/appium.git
synced 2026-03-03 07:39:21 -06:00
docs: translate some documents into Chinese (#20608)
* Finish the translation of the requirements.md file * Finish the translation of the test-rb.md file * Finish the translation of the test-dotnet.md file * Translate the missing parts in test-rb.md
This commit is contained in:
@@ -2,28 +2,23 @@
|
||||
hide:
|
||||
- toc
|
||||
|
||||
title: System Requirements
|
||||
title: 系统要求
|
||||
---
|
||||
|
||||
The basic requirements for the Appium server are:
|
||||
Appium服务器的基本要求是:
|
||||
|
||||
* A macOS, Linux, or Windows operating system
|
||||
* [Node.js](https://nodejs.org) version in the [SemVer](https://semver.org) range `^14.17.0 || ^16.13.0 || >=18.0.0`
|
||||
* LTS is recommended
|
||||
* [`npm`](https://npmjs.com) version `>=8` (`npm` is usually bundled with Node.js, but can be upgraded
|
||||
independently)
|
||||
* macOS、Linux或Windows操作系统
|
||||
* [Node.js](https://nodejs.org) 版本在 `^14.17.0 || ^16.13.0 || >=18.0.0` 范围内
|
||||
* 推荐使用LTS版本
|
||||
* [`npm`](https://npmjs.com) 版本 `>=8` (`npm` 通常与Node.js捆绑在一起,但可以独立升级)
|
||||
|
||||
By itself, Appium is relatively lightweight and doesn't have significant disk space or RAM
|
||||
requirements. It can even be run in resource-constrained environments like Raspberry Pi, so long as
|
||||
Node.js is available.
|
||||
Appium本身相对轻量级,并且没有大量的磁盘空间或RAM要求。
|
||||
只要Node.js可用,它甚至可以在Raspberry Pi等资源有限的环境中运行。
|
||||
|
||||
### Driver Requirements
|
||||
### 驱动程序要求
|
||||
|
||||
Drivers for automating specific platforms will likely have other requirements. Refer to the
|
||||
documentation of the [Appium driver(s)](../ecosystem/drivers.md) for that platform for additional
|
||||
dependencies. It is almost universally the case that Appium drivers for a given platform will
|
||||
require the developer toolchain and SDKs for that platform to be installed.
|
||||
自动化特定平台的驱动程序可能还有其他要求。有关其他依赖关系,请参阅该平台的[Appium驱动程序](../ecosystem/drivers.md)文档。
|
||||
一般情况下,给定平台的Appium驱动程序需要安装该平台的开发人员工具链和SDK。
|
||||
|
||||
In order to assist with driver requirements, each (official) driver comes with the Appium Doctor tool,
|
||||
which allows to verify if all requirements have been set up. Learn more about how to use this tool in
|
||||
the [Command-Line Usage documentation](../cli/extensions.md#doctor).
|
||||
为了协助满足驱动程序的要求,每个官方驱动程序都会配备 Appium Doctor 工具,该工具用于验证当前配置是否已满足驱动程序的所有要求。
|
||||
您可以在[命令行使用文档](../cli/extensions.md#doctor)中了解更多关于如何使用这个工具的信息。
|
||||
|
||||
@@ -2,13 +2,14 @@
|
||||
hide:
|
||||
- toc
|
||||
|
||||
title: Write a Test (.NET)
|
||||
title: 编写一个测试(.NET)
|
||||
---
|
||||
|
||||
The [Appium .NET Client](https://github.com/appium/dotnet-client/) is
|
||||
an official Appium client in C#. This driver is an extension of the Selenium C# client. It has all the functionalities of the regular driver, but add Appium-specific methods on top of this. The driver is available on the public NuGet Gallery as [Appium.WebDriver](https://www.nuget.org/packages/Appium.WebDriver/).
|
||||
[Appium.NET 客户端](https://github.com/appium/dotnet-client/)是 C# 中的官方 Appium 客户端。
|
||||
此驱动程序是 Selenium C# 客户端的扩展。它具有常规驱动程序的所有功能,并在此基础上添加了Appium特定的方法。
|
||||
该驱动程序可在 NuGet Gallery 上以[Appium.WebDriver](https://www.nuget.org/packages/Appium.WebDriver/)的形式提供。
|
||||
|
||||
Now, we get inside the directory and create a new [NUnit](https://nunit.org/) project. We will also add the references to the Appium.Net driver, and other dependencies.
|
||||
现在,我们进入该目录并创建一个新的[NUnit](https://nunit.org/)项目。我们还将添加对 Appium.NET 驱动程序的引用和其他依赖项。
|
||||
|
||||
```bash
|
||||
cd dotnet-client
|
||||
@@ -16,12 +17,12 @@ dotnet new nunit --name appiumtest
|
||||
|
||||
cd appiumtest
|
||||
|
||||
# This will install the latest 5.x version
|
||||
# 这将安装最新的5.x版本
|
||||
dotnet add package Appium.WebDriver --prerelease
|
||||
dotnet add package Newtonsoft.Json --version 13.0.3
|
||||
```
|
||||
|
||||
Once this is done, your project should have a placeholder file `UnitTest1.cs`. We will replace the code to include the OpenQA namespaces, an initialization of the driver, and the actual test.
|
||||
完成此操作后,您的项目应该有一个占位符文件`UnitTest1.cs`。我们将替换代码,以包含OpenQA名称空间、驱动程序的初始化和实际测试。
|
||||
|
||||
```C# title="UnitTest1.cs"
|
||||
using OpenQA.Selenium;
|
||||
@@ -47,7 +48,7 @@ public class Tests
|
||||
|
||||
driverOptions.AddAdditionalAppiumOption("appPackage", "com.android.settings");
|
||||
driverOptions.AddAdditionalAppiumOption("appActivity", ".Settings");
|
||||
// NoReset assumes the app com.google.android is preinstalled on the emulator
|
||||
// NoReset假设模拟器上预装了com.google.android应用程序
|
||||
driverOptions.AddAdditionalAppiumOption("noReset", true);
|
||||
|
||||
_driver = new AndroidDriver(serverUri, driverOptions, TimeSpan.FromSeconds(180));
|
||||
@@ -69,37 +70,31 @@ public class Tests
|
||||
}
|
||||
```
|
||||
|
||||
!!! note
|
||||
!!! 注意
|
||||
|
||||
It's not within the scope of this guide to give a complete run-down on the dotnet client
|
||||
library or everything that's happening here, so we'll leave the code itself unexplained in
|
||||
detail for now. You may want to read up particularly on Appium
|
||||
[Capabilities](../guides/caps.md) in addition to familiarizing yourself with the
|
||||
[dotnet client driver documentation](https://github.com/appium/dotnet-client/) for a fuller explanation
|
||||
of the various API commands you see and what their purpose is.
|
||||
本指南不包括对.NET客户端库或这里发生的一切进行完整的概述,因此我们暂时不详细解释代码本身。
|
||||
除了熟悉[dotnet客户端驱动程序文档](https://github.com/appium/dotnet-client/)外,
|
||||
您可能还想阅读[Appium功能](../guides/caps.md)文档,以更全面地解释您看到的各种API命令及其用途。
|
||||
|
||||
Basically, this code is doing the following:
|
||||
基本上,这段代码正在执行以下操作:
|
||||
|
||||
1. Defining a set of "Capabilities" (parameters) to send to the Appium server so Appium knows what
|
||||
kind of thing you want to automate. Some of these parameters can be overriden using environment variables.
|
||||
1. Starting an Appium session on the built-in Android settings app.
|
||||
1. Finding the "Battery" list item and clicking it.
|
||||
1. Ending the Appium session.
|
||||
1. 定义一组要发送到Appium服务器的“能力”(参数),以便Appium知道您想要自动化什么。其中一些参数可以使用环境变量覆盖。
|
||||
1. 在内置的Android设置应用程序上启动Appium会话。
|
||||
1. 找到“电池”列表项并单击它。
|
||||
1. 结束Appium会话。
|
||||
|
||||
That's it! Let's give it a try. Before you run the test, make sure that you have an Appium server
|
||||
running in another terminal session, otherwise you'll get an error about not being able to connect
|
||||
to one. Then, you can execute the script:
|
||||
就是这样!让我们试试。在运行测试之前,请确保您在另一个终端会话中运行了 Appium 服务器,否则您将收到无法连接到该服务器的错误。然后,您可以执行脚本:
|
||||
|
||||
```bash
|
||||
dotnet test
|
||||
|
||||
# Example output:
|
||||
# 示例输出:
|
||||
# Starting test execution, please wait...
|
||||
# A total of 1 test files matched the specified pattern.
|
||||
|
||||
# Passed! - Failed: 0, Passed: 1, Skipped: 0, Total: 1, Duration: 323 ms - appiumtest.dll (net7.0)
|
||||
```
|
||||
|
||||
If all goes well, you'll see the Settings app open up and navigate to the "Battery" view in the emulator before the app closes again.
|
||||
如果一切顺利,您会看到“设置”应用程序打开,并导航到模拟器中的“电池”视图,然后应用程序关闭。
|
||||
|
||||
Congratulations, you've started your Appium journey! Read on for some [next steps](./next-steps.md) to explore.
|
||||
恭喜,您已经开始了您的Appium之旅!请继续阅读,了解[下一步](./next-steps.md)要探索的内容。
|
||||
|
||||
@@ -2,82 +2,77 @@
|
||||
hide:
|
||||
- toc
|
||||
|
||||
title: Write a Test (Ruby)
|
||||
title: 编写一个测试(Ruby)
|
||||
---
|
||||
|
||||
[AppiumLib](https://github.com/appium/ruby_lib) 和 [AppiumLibCore](https://github.com/appium/ruby_lib_core)(**推荐**)是 Ruby 中的官方 Appium 客户端库,
|
||||
它们可以通过 gem 在 [appium_lib](https://rubygems.org/gems/appium_lib) 和 [appium_lib_core](https://rubygems.org/gems/appium_lib_core) 包名称下获得。
|
||||
appium_lib_core 继承自 Selenium Ruby,appium_lib 继承自 appium_lib_core,因此安装这些库时包括 Selenium 绑定。
|
||||
如果您需要不太复杂的客户端解决方案,我们建议您使用`appium_lib_core`。`appium_lib`有一些`appium_lib_core`没有的有用方法,
|
||||
但代价是更高的复杂性和历史方法,这些方法可能无法在最新环境中工作。
|
||||
|
||||
The [AppiumLib](https://github.com/appium/ruby_lib) and the [AppiumLibCore](https://github.com/appium/ruby_lib_core) (**recommended**) are official Appium client libraries in Ruby, which are available via gem under the [appium_lib](https://rubygems.org/gems/appium_lib) and the [appium_lib_core](https://rubygems.org/gems/appium_lib_core) package names. The appium_lib_core inherits from the Selenium Ruby Binding, and the appium_lib inherits from the appium_lib_core, so installing these libraries include the selenium binding. We recommend `appium_lib_core` if you need a less complex client-side solution. The `appium_lib` has some useful methods the core does not have, but for the cost of greater complexity and historical methods which may not work in the latest environment.
|
||||
|
||||
As the first step, let's initialize a Gemfile to manage the dependency:
|
||||
第一步,让我们初始化Gemfile来管理依赖项:
|
||||
|
||||
```bash
|
||||
bundle init
|
||||
```
|
||||
|
||||
Then, you could add Appium Ruby Client dependency as below:
|
||||
然后,您可以添加Appium Ruby客户端依赖项,如下所示:
|
||||
|
||||
```bash
|
||||
bundle add appium_lib_core
|
||||
# or
|
||||
# 或
|
||||
# bundle add appium_lib
|
||||
```
|
||||
|
||||
Test code example below uses `test-unit` module, thus please run:
|
||||
下面的测试代码示例使用`test-unit`模块,因此请运行:
|
||||
|
||||
```bash
|
||||
bundle add test-unit
|
||||
```
|
||||
|
||||
Once these steps has done, your `Gemfile` file should include:
|
||||
完成这些步骤后,您的`Gemfile`文件应该包括:
|
||||
|
||||
```ruby title="Gemfile"
|
||||
--8<-- "./sample-code/quickstarts/rb/Gemfile"
|
||||
```
|
||||
|
||||
The `appium_lib_core` is the main part as an Appium client.
|
||||
`appium_lib` has various helper methods, but the driver instance was ordinary designed to be used as a global variable. It could causes an issue to handle the instance.
|
||||
`appium_lib_core` does not have such a global variable.
|
||||
`appium_lib_core`是 appium 客户端的主要部分。`appium_lib`有各种辅助方法,但驱动程序实例通常被设计为全局变量。
|
||||
这可能会导致处理实例时出现问题。`appiumlib_core`中没有这样的全局变量。
|
||||
|
||||
This example is by the `appium_lib_core` with `test-unit` gem module.
|
||||
Tes code in `appium_lib` should be similar.
|
||||
这个例子使用了`appium_lib_core`和`test-unit`gem 模块。使用`appium_lib`的代码应该类似。
|
||||
|
||||
```ruby title="test.rb"
|
||||
--8<-- "./sample-code/quickstarts/rb/test.rb"
|
||||
```
|
||||
|
||||
!!! note
|
||||
!!! 注意
|
||||
|
||||
It's not within the scope of this guide to give a complete run-down on the Ruby client
|
||||
library or everything that's happening here, so we'll leave the code itself unexplained in detail for now.
|
||||
本指南不包括对Ruby客户端库或这里发生的一切进行完整的概述,因此我们暂时不详细解释代码本身。
|
||||
|
||||
- 您可能想特别了解[Appium功能](../guides/caps.md)。
|
||||
- 在 appium_lib_core 的 GitHub 仓库中,[功能测试代码](https://github.com/appium/ruby_lib_core/tree/master/test/functional)里可以找到更多的示例。
|
||||
- 在[appium_lib_core](https://www.rubydoc.info/github/appium/ruby_lib_core) 和 [appium_lib](https://www.rubydoc.info/github/appium/ruby_lib) 的文档中也可以帮你找到可用的方法。
|
||||
|
||||
!!! 注意
|
||||
|
||||
- You may want to read up particularly on Appium [Capabilities](../guides/caps.md).
|
||||
- [functional test code](https://github.com/appium/ruby_lib_core/tree/master/test/functional) in the appium_lib_core GitHub repository should help to find more working example.
|
||||
- Documentation [appium_lib_core](https://www.rubydoc.info/github/appium/ruby_lib_core) and [appium_lib](https://www.rubydoc.info/github/appium/ruby_lib) also helps to find available methods.
|
||||
示例代码可从[GitHub Appium存储库](https://github.com/appium/appium/tree/master/packages/appium/sample-code/quickstarts/rb)获得。
|
||||
|
||||
!!! note
|
||||
基本上,这段代码正在执行以下操作:
|
||||
|
||||
The sample code is available from [GitHub Appium repository](https://github.com/appium/appium/tree/master/packages/appium/sample-code/quickstarts/rb).
|
||||
1. 定义一组要发送到Appium服务器的“能力”(参数),以便Appium知道您想要自动化什么。
|
||||
1. 在内置的Android设置应用程序上启动Appium会话。
|
||||
1. 找到“电池”列表项并单击它。
|
||||
1. 暂停片刻,纯粹是为了视觉效果。
|
||||
1. 结束Appium会话。
|
||||
|
||||
|
||||
Basically, this code is doing the following:
|
||||
|
||||
1. Defining a set of "Capabilities" (parameters) to send to the Appium server so Appium knows what
|
||||
kind of thing you want to automate.
|
||||
1. Starting an Appium session on the built-in Android settings app.
|
||||
1. Finding the "Battery" list item and clicking it.
|
||||
1. Pausing for a moment purely for visual effect.
|
||||
1. Ending the Appium session.
|
||||
|
||||
That's it! Let's give it a try. Before you run the test, make sure that you have an Appium server
|
||||
running in another terminal session, otherwise you'll get an error about not being able to connect
|
||||
to one. Then, you can execute the script:
|
||||
就是这样!让我们试试。在运行测试之前,请确保您在另一个终端会话中运行了 Appium 服务器,否则您将收到无法连接到该服务器的错误。然后,您可以执行脚本:
|
||||
|
||||
```bash
|
||||
# Please run "bundle install" first if your environment has not run the installation command yet.
|
||||
# 如果您的环境尚未运行安装命令,请首先运行“bundle install”。
|
||||
bundle exec ruby test.rb
|
||||
```
|
||||
|
||||
If all goes well, you'll see the Settings app open up and navigate to the "Battery" view before the
|
||||
app closes again.
|
||||
如果一切顺利,您会看到“设置”应用程序打开,并导航到“电池”视图,然后应用程序关闭。
|
||||
|
||||
Congratulations, you've started your Appium journey! Read on for some [next steps](./next-steps.md) to explore.
|
||||
恭喜,您已经开始了您的Appium之旅!请继续阅读,了解[下一步](./next-steps.md)要探索的内容。
|
||||
|
||||
Reference in New Issue
Block a user