我的项目使用的是selenium客户端驱动程序0.9,基于硒的集成测试将由maven使用maven selenium插件执行。(stackoverflow中已经有很多问题,但找不到相关的答案)。Selenium测试用例失败并出现错误原因:org.openqa.selence.server.browserlaunchers.FirefoxChromeLauncher$FileLockRemainedException:锁定文件仍然存在!C: \Users\nagappan.s\AppData\Local\Temp\customProfileDir23d2b92949d74270915586b2a3f2073a\parent.lock网址:org.openqa.selence.server.browserlaunchers.FirefoxChromeLauncher.waitForFileLockToGoAway(FirefoxChromeLauncher.java:318)网址:org.openqa.selence.server.browserlaunchers.FirefoxChromeLauncher.waitForFullProfileToBeCreated(FirefoxChromeLauncher.java:365)…还有20个
我自己找到了答案。Maven selenium插件只是启动集线器,而不是启动selenium节点(集成和独立)。在我的案例中,它是selenium 0.9的旧版本,单元测试使用DefaultSelenium,因此它还需要一个节点,通过打开浏览器和控制台来处理浏览器命令。因此,我使用maven antrun插件启动了集线器和节点,以启动类似的服务器和集线器
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.7</version>
<executions>
<execution>
<phase>pre-integration-test</phase>
<configuration>
<target>
<property name="selenium.server.dir" value="${basedir}" />
<path id="selenium.classpath">
<fileset dir="${selenium.server.dir}">
<include name="selenium*.jar" />
</fileset>
</path>
<java classname="org.openqa.grid.selenium.GridLauncher"
classpathref="selenium.classpath"
failonerror="true"
fork="false">
<arg line="-role hub"/>
</java>
<java classname="org.openqa.grid.selenium.GridLauncher"
classpathref="selenium.classpath"
failonerror="true"
fork="false">
<arg line="-role node
-hub http://localhost:4444/grid/register"/>
</java>
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
它现在运行得很好。