Skip to content

Add Chinese translation of "remote_webdriver_server" #384

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,77 +1,70 @@
---
title: "Remote WebDriver server"
title: "远程WebDriver服务器"
weight: 1
---

{{% notice info %}}
<i class="fas fa-language"></i> 页面需要从英语翻译为简体中文。
您熟悉英语与简体中文吗?帮助我们翻译它,通过 pull requests 给我们!
{{% /notice %}}
服务器将始终在安装了待测浏览器的机器上运行.
可以从命令行或通过代码配置来使用服务器.

The server will always run on the machine with the browser you want to
test. The server can be used either from the command line or through code
configuration.

## 从命令行启动服务器

## Starting the server from the command line

Once you have downloaded `selenium-server-standalone-{VERSION}.jar`,
place it on the computer with the browser you want to test. Then, from
the directory with the jar, run the following:
下载 `selenium-server-standalone-{VERSION}.jar` 后,
将其传到具有待测浏览器的电脑上.
然后, 切换到包含此jar文件的目录中, 运行以下命令:

```shell
java -jar selenium-server-standalone-{VERSION}.jar
```

## Considerations for running the server
## 运行服务器的注意事项

The caller is expected to terminate each session properly, calling
either `Selenium#stop()` or `WebDriver#quit`.
调用者应调用 `Selenium#stop()` 或 `WebDriver#quit` 以结束每次会话.

The selenium-server keeps in-memory logs for each ongoing session,
which are cleared when `Selenium#stop()` or `WebDriver#quit` is called. If
you forget to terminate these sessions, your server may leak memory. If
you keep extremely long-running sessions, you will probably need to
stop/quit every now and then (or increase memory with -Xmx jvm option).
Selenium服务器在内存中保留每个运行会话的日志,
这些日志将在调用 `Selenium#stop()` `WebDriver#quit` 时清除.
如果您忘记终止这些会话, 则可能会造成服务器内存泄漏.
如果您保持运行时间非常长的会话,
则可能需要不时执行停止或退出的操作 (或使用-Xmx jvm选项增加内存) .


## Timeouts (from version 2.21)
## 超时 (自2.21版本)

The server has two different timeouts, which can be set as follows:
服务器有两种不同的超时, 可以按如下设置:

```shell
java -jar selenium-server-standalone-{VERSION}.jar -timeout=20 -browserTimeout=60
```

* browserTimeout
* Controls how long the browser is allowed to hang (value in seconds).
* 控制允许浏览器挂起的时间
(以秒为单位的值) .
* timeout
* Controls how long the client is allowed to be gone
before the session is reclaimed (value in seconds).
* 控制在回收会话之前允许客户端离开的时间
(以秒为单位的值) .

The system property `selenium.server.session.timeout`
is no longer supported as of 2.21.
从2.21版本开始不再支持系统属性
`selenium.server.session.timeout`.

Please note that the `browserTimeout`
is intended as a backup timeout mechanism
when the ordinary timeout mechanism fails,
which should be used mostly in grid/server environments
to ensure that crashed/lost processes do not stay around for too long,
polluting the runtime environment.
请注意, 当常规超时机制发生故障时,
`browserTimeout`旨在用作备份超时机制,
该机制应主要在网格和服务器的环境中使用,
以确保崩溃或丢失的进程不会驻留太长时间,
从而干扰了运行时环境.


## Configuring the server programmatically
## 以编程方式配置服务器

In theory, the process is as simple as mapping the `DriverServlet` to
a URL, but it's also possible to host the page in a lightweight
container, such as Jetty configured entirely in code. Steps to do this
follow.
从理论上讲, 此过程就像将 `DriverServlet`映射到URL一样简单,
但是也可以将页面托管在轻量级容器中,
例如完全用代码配置的Jetty.
步骤如下.

* Download the `selenium-server.zip` and unpack.
* Put the JARs on the CLASSPATH.
* Create a new class called `AppServer`. Here, I'm using
Jetty, so you'll need to [download](//www.eclipse.org/jetty/download.html)
that as well:
* 下载并解压 `selenium-server.zip`.
* 将这些Jar设置在CLASSPATH中.
* 创建一个名为 `AppServer`的新类.
在这里, 我使用Jetty,
因此您也需要[download](//www.eclipse.org/jetty/download.html):

```java
import org.mortbay.jetty.Connector;
Expand Down