微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

java – 未找到符号:使用maven运行selenium时

嗨我在运行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>

PATH到我的机器上的selenium服务器类.一切都在那里,我查了一下.

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

解决方法:

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

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

出于本教程的目的,回滚到0.9版本是最简单的,然后一旦您更熟悉API,请回到1.0.1并相应地重构.

这是1.0 version的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" 

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐