Maven Selenium Plugin - Lock File still present error

╄→гoц情女王★ 提交于 2019-12-25 18:34:04

问题


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


回答1:


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>

It works now perfectly.



来源:https://stackoverflow.com/questions/29101249/maven-selenium-plugin-lock-file-still-present-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!