【问题标题】:Maven Selenium Plugin - Lock File still present errorMaven Selenium 插件 - 锁定文件仍然存在错误
【发布时间】:2015-03-17 14:08:39
【问题描述】:

我的项目使用 selenium-client-driver 0.9,基于 selenium 的集成测试将由 maven 使用 maven-selenium-plugin 执行。 (stackoverflow 中已经有很多问题,但找不到相关的答案)。 Selenium 测试用例失败并出现错误 引起:org.openqa.selenium.server.browserlaunchers.FirefoxChromeLauncher$FileLockRemainedException:锁定文件仍然存在! C:\Users\nagappan.s\AppData\Local\Temp\customProfileDir23d2b92949d74270915586b2a3f2073a\parent.lock 在 org.openqa.selenium.server.browserlaunchers.FirefoxChromeLauncher.waitForFileLockToGoAway(FirefoxChromeLauncher.java:318) 在 org.openqa.selenium.server.browserlaunchers.FirefoxChromeLauncher.waitForFullProfileToBeCreated(FirefoxChromeLauncher.java:365) ... 20 更多

【问题讨论】:

  • 我不知道为什么它是专门的......我已经阅读了stackoverflow的所有答案并尝试过但没有成功。俗话说,如果我们在 Firefox 中使用配置文件并尝试打开另一个文件锁定文件将不允许它发生。但是在关闭所有 Firefox 窗口后,它也会以同样的方式发生。它也有不推荐使用的版本,它没有任何支持,我不能转移到新版本的 java。

标签: java selenium junit


【解决方案1】:

我自己找到了答案。 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>

现在完美运行。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-03-26
    • 1970-01-01
    • 2012-12-15
    • 2016-07-25
    • 1970-01-01
    • 2017-02-25
    相关资源
    最近更新 更多