缺少用于从 Java 启动 Selenium 服务器的 JAR

发布于 2024-11-15 16:33:24 字数 258 浏览 1 评论 0原文

我对 Selenium 完全陌生,我使用的是 2.0rc2 版本。我已经看到很多资源展示了如何通过 Java 以编程方式启动服务器,但令我困惑的是 Selenium 2.0rc2 的两个 JAR 没有包 org.openqa.selenium.server.SeleniumServer< /code> 我需要导入才能执行此操作。

2.0 中是否已弃用此功能来代替其他内容?如果是这样,我如何从 Java 启动服务器?如果没有,为什么导入不存在?

I'm completely new to Selenium, and I'm using version 2.0rc2. I've seen a lot of resources showing how to start the server programmatically through Java, but what has me confused is that the two JARs for Selenium 2.0rc2 do not have the package org.openqa.selenium.server.SeleniumServer I need to import in order to do this.

Has this been deprecated in place of something different in 2.0? If so, how do I start the server from Java? If not, why is that import not there?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

凡尘雨 2024-11-22 16:33:24

这取决于你想做什么。最简单的设置方法是下载独立 jar 并将其添加到构建路径中。这将添加 selenium 及其所有依赖项。

现在您实际上已经可以非常非常简单地开始了。 这是一个非常不错的起点,但其中的示例使用的是较旧的 API。现在应该通过高级用户交互来完成操作。

要了解 SeleniumServer 的用途,您必须了解有两种使用 Selenium 的方法。您可以使用“客户端”,它是处理浏览器启动等的语言绑定。一个例子是:

WebDriver driver = new InternetExplorerDriver();
driver.get("http://www.google.co.uk");
driver.quit();

这应该启动一个 Internet Explorer 实例,转到 google 并立即退出。代码的“服务器”端是您可以在计算机上启动服务器实例并将代码连接到它的地方。这可以通过编程方式完成,但通过命令行也可以更轻松地完成。您下载的 JAR 可以使用“java -jar”调用,并提供 Selenium API。例如,如果您进入命令提示符并执行以下操作:

java -jar selenium.jar .... 

假设您提供了有效的参数,它将启动一个服务器实例,等待代码连接到它。我实际上并不能 100% 确定这是否适用于 SeleniumRC(1.0 API)或 WebDriver(2.0 API)。

为了直接回答您的问题,我刚刚下载了 standalone 包含 SeleniumServer。

It depends what it is you want to do. The easiest way for you to get set up is to download the standalone-jar and add it to your buildpath. This will add the selenium stuff as well as all its dependencies.

Now you can actually already start off very very simply. This is a very decent place to get started but the examples there are using older APIs. Actions should now be done with advanced user interactions.

To understand what SeleniumServer is for you must understand there are two ways to use Selenium. You can either use the 'client' which are language bindings which deal with browser launching, etc. An example of this is:

WebDriver driver = new InternetExplorerDriver();
driver.get("http://www.google.co.uk");
driver.quit();

This should launch an instance of internet explorer, go to google and immediately exit. The 'server' side of the code is where you can launch an instance of a server on a machine and have your code connect to it. This can be done programmatically but also more easily via the command line. The JAR you downloaded can be invoked with 'java -jar' as well as providing the Selenium API. For example if you went to a command prompt and did:

java -jar selenium.jar .... 

Assuming you gave valid arguments it would kick off a server instance which waits for code to connect to it. I'm actually not 100% sure whether this is for SeleniumRC (1.0 API) or WebDriver (2.0 API).

To answer your question directly I just downloaded the standalone which does contain SeleniumServer.

铁轨上的流浪者 2024-11-22 16:33:24

在这里,将其添加到您的 CLASSPATH 中:

http://repo1.maven.org/maven2/org/seleniumhq/selenium/selenium-server/2.0rc2/selenium-server-2.0rc2.jar

如果您使用的是maven,只需添加到您的pom.xml:

<dependency>
  <groupId>org.seleniumhq.selenium</groupId>
  <artifactId>selenium-server</artifactId>
  <version>2.0rc2</version>
</dependency>

顺便说一句,org.openqa.selenium.server.SeleniumServer是位于内部的类org.openqa.selenium.server 包。

Here it is, add this to your CLASSPATH:

http://repo1.maven.org/maven2/org/seleniumhq/selenium/selenium-server/2.0rc2/selenium-server-2.0rc2.jar

If you are using maven, simply add to your pom.xml:

<dependency>
  <groupId>org.seleniumhq.selenium</groupId>
  <artifactId>selenium-server</artifactId>
  <version>2.0rc2</version>
</dependency>

BTW org.openqa.selenium.server.SeleniumServer is a class located inside org.openqa.selenium.server package.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文