2

我正在使用 Eclipse 和 Selenium RC 使用 TestNG 运行 Selenium。我使用了命令:

selenium.captureEntirePageScreenshot("\\test.png","");

但出现以下错误:

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: Component returned failure code: 0x80520001 (NS_ERROR_FILE_UNRECOGNIZED_PATH) [nsILocalFile.initWithPath]



有人可以建议为什么会发生此错误吗?我已经尝试过以下方法:

1)用“background=#CCFFDD”替换“”(字符串kwargs参数)

2) 在 Firefox 中以 chrome 模式运行

3)将路径更改为以下值,我仍然收到错误:“\test.jpg”、“c:\test.jpg”、“c:\test.png”、“c:\folder1\test .png", (folder1 存在) "c:\folder1\test.jpg",

4) 尝试使用 - selenium.captureScreenshot("\test.png"); 它工作正常,但不能解决我的目的,我不想使用awt。

有人可以建议可能出了什么问题吗?

谢谢,
穆根

4

4 回答 4

1

试试这个:

String path = System.getProperty("user.dir");
selenium.captureEntirePageScreenshot(path + "\\test.png", "");
于 2011-02-18T06:23:09.710 回答
1

更好的是...

我遇到了类似的问题,我只能访问相对路径而不是绝对路径。这是我想出的解决方案:

public void saveScreenshot(String methodName) {
    if (methodName == null) {
        methodName = String.valueOf(System.currentTimeMillis());
    }
    File f = new File("reports" + File.separator + methodName + ".jpg");
    selenium.captureEntirePageScreenshot(f.getAbsolutePath(), "");
}

这会将整个页面的屏幕截图放入reports与项目相关的目录中。我使用方法名称作为文件名,或者如果将 null 发送到方法,则使用当前时间。

于 2011-04-01T18:51:40.557 回答
0

致相关负责人,。在我不断摆弄代码并重新启动系统后,问题得到了解决。我开始知道 captureEntirePageScreenshot 仅适用于绝对路径,所以我确保我一直在尝试。

于 2009-09-18T12:58:43.343 回答
-1

在查看此页面后,我得到了它的工作。

http://ashishbhatt.wordpress.com/2010/02/03/using-captureentirepagescreenshot-with-selenium/

于 2010-02-28T20:52:50.613 回答