Maven Selenium插件-锁定文件仍然存在错误 [英] Maven Selenium Plugin - Lock File still present error

查看:73
本文介绍了Maven Selenium插件-锁定文件仍然存在错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的项目使用的是selenium-client-driver 0.9,基于selenium的集成测试将由maven使用maven-selenium-plugin执行. (stackoverflow中已经有很多问题,但是找不到相关的答案).硒测试用例因错误而失败 原因: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个

My Project is using selenium-client-driver 0.9 and selenium based integration test will be executed by maven using maven-selenium-plugin. (There are already many questions in stackoverflow but couldnt find a relavant answer). Selenium test case fails with error Caused by: org.openqa.selenium.server.browserlaunchers.FirefoxChromeLauncher$FileLockRemainedException: Lock file still present! C:\Users\nagappan.s\AppData\Local\Temp\customProfileDir23d2b92949d74270915586b2a3f2073a\parent.lock at org.openqa.selenium.server.browserlaunchers.FirefoxChromeLauncher.waitForFileLockToGoAway(FirefoxChromeLauncher.java:318) at org.openqa.selenium.server.browserlaunchers.FirefoxChromeLauncher.waitForFullProfileToBeCreated(FirefoxChromeLauncher.java:365) ... 20 more

推荐答案

我自己找到了答案. Maven硒插件仅启动集线器,而不启动硒节点(集成的和独立的).在我的情况下,它是selenium 0.9的旧版本,并且单元测试使用DefaultSelenium,因此它还需要一个节点,该节点也可以通过打开浏览器和控制台来处理浏览器命令.因此,我使用maven antrun插件启动了集线器和节点,以启动服务器和集线器,例如

I found the answer by myself. Maven selenium plugin just start the hub and not the selenium node (both integrated and standalone). In my case, it is old version of selenium 0.9 and unit testing uses DefaultSelenium so it require a node also which process browser commands by opening browser and console. So i started the hub and node using maven antrun plugin to start the server and hub like

<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>

现在可以正常工作了.

这篇关于Maven Selenium插件-锁定文件仍然存在错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆