问题立即运行失败的JUnit测试?

时间:2013-06-12 06:02:09

标签: java selenium jenkins automation webdriver

我有一组随机失败的Selenium WebDriver测试,我想只重新运行那些立即失败的测试,试试3次。 我使用多个浏览器在网格上运行测试,我猜这会导致问题。 我按照How to Re-run failed JUnit tests immediately?中给出的解决方案进行了操作 但是每当它试图运行失败的测试时我们都会得到这个异常

错误消息

org.openqa.selenium.remote.SessionNotFoundException: Session ID is null
Build info: version: '2.32.0', revision: '6c40c18', time: '2013-04-09 17:23:22'
System info: os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.6.0_26'
Driver info: driver.version: RemoteWebDriver
Stacktrace

java.lang.RuntimeException: org.openqa.selenium.remote.SessionNotFoundException: Session ID is null
Build info: version: '2.32.0', revision: '6c40c18', time: '2013-04-09 17:23:22'
System info: os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.6.0_26'
Driver info: driver.version: RemoteWebDriver
    at au.com.cgu.harvest.automation.rule.AbstractWebDriverManager.classFinished(AbstractWebDriverManager.java:77)
    at au.com.cgu.harvest.automation.rule.ClassFinishRule.finished(ClassFinishRule.java:48)
    at au.com.cgu.harvest.automation.scenario.RetryTest$1.evaluate(RetryTest.java:41)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
    at java.util.concurrent.FutureTask.run(FutureTask.java:138)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    at java.lang.Thread.run(Thread.java:662)
Caused by: org.openqa.selenium.remote.SessionNotFoundException: Session ID is null
Build info: version: '2.32.0', revision: '6c40c18', time: '2013-04-09 17:23:22'
System info: os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.6.0_26'
Driver info: driver.version: RemoteWebDriver
    at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:273)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:527)
    at org.openqa.selenium.remote.RemoteWebDriver.executeScript(RemoteWebDriver.java:463)
    at au.com.cgu.harvest.automation.rule.AbstractWebDriverManager.classFinished(AbstractWebDriverManager.java:65)

`

1 个答案:

答案 0 :(得分:0)

虽然我的情况略有不同,但我遇到了同样的错误消息。你在代码中使用WebDrive close()方法吗?我能够通过使用WebDriver quit()方法解决问题。

来自javadocs的{p>:http://selenium.googlecode.com/svn/trunk/docs/api/java/index.html

//关闭当前窗口,如果它是当前打开的最后一个窗口,则退出浏览器。

接近()

//退出此驱动程序,关闭每个关联的窗口。

退出()