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

Java 未找到符号:使用maven运行selenium时,java,maven-2,continuous-integration,selenium,Java,Maven 2,Continuous Integration,Selenium,嗨,我在运行mvn-e集成测试时遇到了一个符号未找到错误。如果包在我的存储库中,为什么会发生这种情况?我试过下载它并手动安装,但没有什么不同。这是maven中常见的错误吗 我用的是vista家庭版 错误消息 [INFO] ------------------------------------------------------------------------ [ERROR] BUILD FAILURE [INFO] -------------------------------------

嗨,我在运行
mvn-e集成测试时遇到了一个符号未找到错误。如果包在我的存储库中,为什么会发生这种情况?我试过下载它并手动安装,但没有什么不同。这是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
正在使用的教程。

聚甲醛


4.0.0
myapp
com.mycompany
1.0-快照
功能测试
功能测试
聚甲醛
org.seleniumhq.selenium.client-drivers
selenium java客户端驱动程序
1
测试
org.openqa.selenium.server
硒服务器
1.0.1
测试
org.testng
testng
5.1
测试
jdk15
src/it
org.apache.maven.plugins
maven编译器插件
测试编译
1.5
1.5
org.apache.maven.plugins
maven surefire插件
2.4.3
集成测试
测试
src/it/testng.xml
我的计算机上selenium服务器类的路径。一切都在那里,我检查过了

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


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

如果我可以在线找到SeleniumServer的javadocs,那么就有可能建议使用哪个javadocs。

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

我能看到的唯一差异是教程中的selenium服务器和selenium java客户端驱动程序版本为0.9版。查看源代码,在1.0.1版本中已删除了接受int的构造函数

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

以下是的Javadoc(与比较),表明端口(构造函数的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" 

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

或者在需要传递配置选项时使用

**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" 
@BeforeSuite
public void startSeleniumServer() throws Exception {
  seleniumServer = new SeleniumServer();
  seleniumServer.start();
}