Java 在ant中作为junit运行的Selenium会提前关闭浏览器,但不会在IDE中关闭

Java 在ant中作为junit运行的Selenium会提前关闭浏览器,但不会在IDE中关闭,java,firefox,ant,junit,selenium,Java,Firefox,Ant,Junit,Selenium,我在JUnit类中设置了大量selenium测试用例作为四种方法。第一个运行良好,但其余三个在方法的最后一步完成之前关闭Firefox浏览器,给出了一个 ERROR: Command execution failure. Please search the forum at http://clearspace.openqa.org for error details from the log window. The error message is: this.page().currentDo

我在JUnit类中设置了大量selenium测试用例作为四种方法。第一个运行良好,但其余三个在方法的最后一步完成之前关闭Firefox浏览器,给出了一个

ERROR: Command execution failure. Please search the forum at http://clearspace.openqa.org for error details from the log window.  The error message is: this.page().currentDocument is undefined
com.thoughtworks.selenium.SeleniumException: ERROR: Command execution failure. Please search the forum at http://clearspace.openqa.org for error details from the log window.  The error message is: this.page().currentDocument is undefined
安装程序如下所示:

基于蚂蚁的执行

  • Java 1.5
  • Eclipse 3.5
  • Selenium服务器1.0.1
  • Selenium客户端驱动程序1.0.1
IDE

  • Java 1.5
  • Eclipse 3.5
  • Selenium服务器1.0.1
  • Selenium客户端驱动程序1.0.1
我希望找到根本原因


它正在以下线路上崩溃:

这是对user-extensions.js文件的修改:

Selenium.prototype.getElementBody = function(elementId) {
return this.outerHTML(this.page().currentDocument.getElementById(elementId));
};
这就是所谓的:

commandProcessor.getString("getElementBody", "idOfElement");

你能给我们看看你的JUnit测试类吗

我从个人经验中了解到,有时候Selenium测试可能会因为没有明显的原因而崩溃,但您的问题似乎每次都在发生,因此可能与您的代码/脚本有关


如果没有更多的细节,恐怕我无法帮助您。

我从未在Selenium API中见过名为getString的命令,所以我想这就是您的测试失败的原因

另一件事是,您是否告诉Selenium RC使用您使用以下
-userExtensions-user extensions.js
参数修改的user-extensions.js文件?我从未发现在Se:RC中使用用户扩展而使用.getEval()命令是有益的

您需要的是selenium.getEval(“this.browserbot.getUserWindow().getElementByID(id.outerHTML”)

我已经为您清理了JavaScript。
this.browserbot.getUserWindow()
允许您访问包含页面的Selenium JavaScript对象


我希望这会有所帮助

您能给我们一些代码,让我们看看问题出在哪里吗?