Selenium1.0.1+Firefox3.6+Unable to delete parent.lock file

上一篇 / 下一篇  2010-04-21 19:25:53 / 个人分类:Selenium

工具: selenium RC 1.0.1 + Junit
测试浏览器:Firefox3.6
在执行脚本过程中遇到如下问题
java.lang.RuntimeException: Could not start Selenium session: Failed to start new browser session: Unable to delete file F:\temp\customProfileDir62d458aab59f4972a95342789f4262b8\parent.lock
    at com.thoughtworks.selenium.DefaultSelenium.start(DefaultSelenium.java:89)
    at firefox.Registerfailed.setUp(Registerfailed.java:14)
    at junit.framework.TestCase.runBare(TestCase.java:128)
    at com.thoughtworks.selenium.SeleneseTestCase.runBare(SeleneseTestCase.java:212)
    at junit.framework.TestResult$1.protect(TestResult.java:110)
    at junit.framework.TestResult.runProtected(TestResult.java:128)
    at junit.framework.TestResult.run(TestResult.java:113)
    at junit.framework.TestCase.run(TestCase.java:120)
    at junit.framework.TestSuite.runTest(TestSuite.java:228)
    at junit.framework.TestSuite.run(TestSuite.java:223)
    at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:128)
    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
Caused by: com.thoughtworks.selenium.SeleniumException: Failed to start new browser session: Unable to delete file F:\temp\customProfileDir62d458aab59f4972a95342789f4262b8\parent.lock
    at com.thoughtworks.selenium.HttpCommandProcessor.throwAssertionFailureExceptionOrError(HttpCommandProcessor.java:97)
    at com.thoughtworks.selenium.HttpCommandProcessor.doCommand(HttpCommandProcessor.java:91)
    at com.thoughtworks.selenium.HttpCommandProcessor.getString(HttpCommandProcessor.java:262)
    at com.thoughtworks.selenium.HttpCommandProcessor.start(HttpCommandProcessor.java:223)
    at com.thoughtworks.selenium.DefaultSelenium.start(DefaultSelenium.java:81)
    ... 15 more

分析问题:
 * 查看进程,有N个FIREFOX的进程在运行.
 * 查看了N次资料,好像是1.0.1与FIREFOX3.6不太兼容
解决方案:
 * 下载最新的selenium 1.0.3可以实现也FIREFOX3.6的兼容
 * 第二种解决方案:这篇文档中的资料 (http://3lncr.wordpress.com/2010/03/04/selenium-rc-0-1-1-and-firefox-3-6-profile-issue/)

3lncr's blog

As simple as possible, but not any simpler…

Firefox 3.6, Selenium 1.0.1 with selenium-rc-0.1.1 and “Lock file still present!” issue

leave a comment »

Have you just updated your shiny Firefox to version 3.6 and now you can’t make Selenium 1.0.1 (precisely: selenium-rc-0.1.1) working fine for you on this browser? Ooops… I got the same.:(

Now, when you try to run one of your Selenium based UI tests on such a brand-new-and-up-to-date “combo” it just fails to start the browser and there is just some annoying exceptions in logs, similar to these:

ERROR - Failed to start new browser session, shutdown browser and clear all session data java.lang.RuntimeException: Firefox refused shutdown while preparing a profile

org.openqa.selenium.server.browserlaunchers.FirefoxChromeLauncher$
FileLockRemainedException: Lock file still present! C:\DOCUME~1\{windows-username}\LOCALS~1\Temp\customProfileDir197b3da3c02244fb8407912c5e126b07\parent.lock

Caused by: com.thoughtworks.selenium.SeleniumException: Failed to start new browser session: Unable to delete file C:\DOCUME~1\{windows-username}\LOCALS~1\Temp\customProfileDir197b3da3c02244fb8407912c5e126b07\parent.lock

There is a cure. A bit hacky, but still worth to try, if you really need to use Firefox 3.6.

So do some search through your project dependencies JARs and find selenium-server.jar item. Unzip it, find all (of 5) “install.rdf” files inside this JAR (they are under customProfileDirCUSTFF and customProfileDirCUSTFFCHROME subfolders), open them in some text editing tool (they are XML based configuration files) and replace the max version of agent (browser) application from line like this:

<em:maxVersion>3.5.*</em:maxVersion>

into this:

<em:maxVersion>3.6.*</em:maxVersion>

Or just download customized selenium-server.jar (pathed, as above, to Firefox 3.6.*) fromthis place.

Note: If you are using Grails with Selenium plugin (selenium-rc-0.1.1), you can find selenium-server.jar in your project plugins folder (e.g. {user-home}\.grails\{grails-version}\projects\{project-name}\plugins\selenium-rc-0.1.1\lib\server)

Where:
{user-home}stands for user home folder, e.g. C:\DOCUME~1\johndoe or C:\Users\johndoe
{grails-version}is Grails version, e.g. 1.1
{project-name}is your Grails project name, e.g. test-project

Done. It should work now!




TAG: file Selenium selenium lock

 

评分:0

我来说两句

Open Toolbar