未找到符号:使用 Maven 运行 selenium 时

发布于 2024-08-06 01:24:45 字数 3894 浏览 6 评论 0原文

您好,在运行 mvn -e Integration-test 时,我收到符号未找到错误。如果该包位于我的存储库中,为什么会发生这种情况?我尝试过下载并手动安装,但没有什么区别。这是 Maven 中的常见错误吗?

我使用的是vista家庭版,

错误消息

[INFO] ------------------------------------------------------------------------
[ERROR] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Compilation failure
D:\MyWorks\steps\step6\functest\src\it\com\mycompany\app\functest\FirstTest.java:[22,25] cannot find symbol
symbol  : constructor SeleniumServer(int)
location: class org.openqa.selenium.server.SeleniumServer

正在使用教程。 http:// /binil.wordpress.com/2006/12/08/automated-smoke-tests-with-selenium-cargo-testng-and-maven/

POM

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <parent>
    <artifactId>myapp</artifactId>
    <groupId>com.mycompany</groupId>
    <version>1.0-SNAPSHOT</version>
  </parent>

 <artifactId>functest</artifactId>
  <name>functional-tests</name>
  <packaging>pom</packaging>

  <dependencies>
    <dependency>
      <groupId>org.seleniumhq.selenium.client-drivers</groupId>
      <artifactId>selenium-java-client-driver</artifactId>
      <version>1.0</version>
      <scope>test</scope>
    </dependency>

     <dependency>
      <groupId>org.openqa.selenium.server</groupId>
      <artifactId>selenium-server</artifactId>
      <version>1.0.1</version>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>org.testng</groupId>
      <artifactId>testng</artifactId>
      <version>5.1</version>
      <scope>test</scope>
      <classifier>jdk15</classifier>
    </dependency>
  </dependencies>

  <build>
    <testSourceDirectory>src/it</testSourceDirectory>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <executions>
          <execution>
            <goals>
              <goal>testCompile</goal>
            </goals>
          </execution>
        </executions>
        <configuration>
          <source>1.5</source>
          <target>1.5</target>
        </configuration>
      </plugin>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>2.4.3</version>
        <executions>
          <execution>
            <phase>integration-test</phase>
            <goals>
              <goal>test</goal>
            </goals>
          </execution>
        </executions>
        <configuration>
          <suiteXmlFiles>
            <suiteXmlFile>src/it/testng.xml</suiteXmlFile>
          </suiteXmlFiles>
        </configuration>
      </plugin>
    </plugins>
  </build>
</project>

我的机器上的 selenium 服务器类的 路径。一切都在那里,我检查过。

.m2\repository\org\openqa\selenium\server\selenium-server\1.0.1\selenium-server-1.0.1.jar\org\openqa\selenium\server\

Hi I'm getting a symbol not found error, when running mvn -e integration-test. Why could this happen if the package is in my repository? I have tried downloading it and installing it manually but it does not make a difference. Is this a common error in maven?

I'm using vista home edition,

Error message

[INFO] ------------------------------------------------------------------------
[ERROR] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Compilation failure
D:\MyWorks\steps\step6\functest\src\it\com\mycompany\app\functest\FirstTest.java:[22,25] cannot find symbol
symbol  : constructor SeleniumServer(int)
location: class org.openqa.selenium.server.SeleniumServer

Tutorial being used.
http://binil.wordpress.com/2006/12/08/automated-smoke-tests-with-selenium-cargo-testng-and-maven/

POM

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <parent>
    <artifactId>myapp</artifactId>
    <groupId>com.mycompany</groupId>
    <version>1.0-SNAPSHOT</version>
  </parent>

 <artifactId>functest</artifactId>
  <name>functional-tests</name>
  <packaging>pom</packaging>

  <dependencies>
    <dependency>
      <groupId>org.seleniumhq.selenium.client-drivers</groupId>
      <artifactId>selenium-java-client-driver</artifactId>
      <version>1.0</version>
      <scope>test</scope>
    </dependency>

     <dependency>
      <groupId>org.openqa.selenium.server</groupId>
      <artifactId>selenium-server</artifactId>
      <version>1.0.1</version>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>org.testng</groupId>
      <artifactId>testng</artifactId>
      <version>5.1</version>
      <scope>test</scope>
      <classifier>jdk15</classifier>
    </dependency>
  </dependencies>

  <build>
    <testSourceDirectory>src/it</testSourceDirectory>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <executions>
          <execution>
            <goals>
              <goal>testCompile</goal>
            </goals>
          </execution>
        </executions>
        <configuration>
          <source>1.5</source>
          <target>1.5</target>
        </configuration>
      </plugin>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>2.4.3</version>
        <executions>
          <execution>
            <phase>integration-test</phase>
            <goals>
              <goal>test</goal>
            </goals>
          </execution>
        </executions>
        <configuration>
          <suiteXmlFiles>
            <suiteXmlFile>src/it/testng.xml</suiteXmlFile>
          </suiteXmlFiles>
        </configuration>
      </plugin>
    </plugins>
  </build>
</project>

PATH to selenium server class on my machine. Everything is there, I checked.

.m2\repository\org\openqa\selenium\server\selenium-server\1.0.1\selenium-server-1.0.1.jar\org\openqa\selenium\server\

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

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

发布评论

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

评论(3

往事随风而去 2024-08-13 01:24:45

int (端口)作为参数的构造函数确实已被删除(请参阅变更集:2260)。因此,请使用无参数构造函数 SeleniumServer() 创建您的 SeleniumServer (4444 是默认端口):

@BeforeSuite
public void startSeleniumServer() throws Exception {
  seleniumServer = new SeleniumServer();
  seleniumServer.start();
}

或者使用 SeleniumServer(RemoteControlConfiguration 配置) if您需要传递配置选项。

The constructor taking an int (the port) as parameter has indeed been removed (see Changeset:2260). So use the no-arg constructor SeleniumServer() to create your SeleniumServer (4444 is the default port anyway) :

@BeforeSuite
public void startSeleniumServer() throws Exception {
  seleniumServer = new SeleniumServer();
  seleniumServer.start();
}

Or use SeleniumServer(RemoteControlConfiguration configuration) if you need to pass configuration options.

小糖芽 2024-08-13 01:24:45

听起来您列为依赖项的版本 (1.0.1) 中不再存在构造函数 SeleniumServer(int)

如果我可以在线找到 SeleniumServer 的 javadoc,那么可能会建议使用哪一个。

Sounds like the constructor SeleniumServer(int) no longer exists in the version (1.0.1) you have listed as your dependency.

If I could find javadocs for SeleniumServer online then it might be possible to suggest which one to use.

茶底世界 2024-08-13 01:24:45

错误的类(org.openqa.selenium.server.SeleniumServer)是在您已经列出的 selenium-server 依赖项中定义的。

我看到的唯一差异是教程中的 selenium-server 和 selenium-java-client-driver 版本为 0.9 版本。查看源代码,采用 int 的构造函数已在 1.0.1 版本中删除。

出于本教程的目的,最简单的方法是回滚到 0.9 版本,然后在您更熟悉 API 后,回滚到 1.0.1 并进行相应的重构。

这是 1.0 版本 的 Javadoc(与0.9 version),表明端口(构造函数的 int 参数)现在只能作为命令行参数传递给 main 方法:

**main**

public static void main(java.lang.String[] args)
             throws java.lang.Exception

Starts up the server on the specified port (or default if no port was specified) and then starts interactive mode if specified.

Parameters:
    args - - either "-port" followed by a number, or "-interactive" 

The class in error (org.openqa.selenium.server.SeleniumServer) is defined in the selenium-server dependency you already have listed.

The only discrepancy that I can see is that the selenium-server and selenium-java-client-driver versions in the tutorial are at version 0.9. Looking at the sources the constructor taking an int has been removed in the 1.0.1 version.

For the purpose of the tutorial it would be simplest to roll back to the 0.9 version, then once you're more familiar with the API, move back up to 1.0.1 and refactor accordingly.

Here's the Javadoc for the 1.0 version (compare with the 0.9 version), indicating that the port (the int argument to the constructor) can now only be passed as a command-line argument to the main method:

**main**

public static void main(java.lang.String[] args)
             throws java.lang.Exception

Starts up the server on the specified port (or default if no port was specified) and then starts interactive mode if specified.

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