selenium.captureEntirePageScreenshot 不起作用,但 selenium.captureScreenshot 起作用

发布于 2024-08-04 05:20:32 字数 882 浏览 3 评论 0原文

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

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)将“”(字符串 kwargs 参数)替换为“background=#CCFFDD”

2)在 Firefox 中以 chrome 模式运行

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

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

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

谢谢,
无限

I'm running Selenium with TestNG using Eclipse and Selenium RC. I used the command:

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

but got the following error:

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]

Can someone please suggest why this error is occuring? I have already tried the following:

1)Replaced "" (String kwargs parameter) with "background=#CCFFDD"

2)Running in Firefox in chrome mode

3)Changed the path to the following values and I'm still getting the error:
"\test.jpg",
"c:\test.jpg",
"c:\test.png",
"c:\folder1\test.png", (folder1 exists)
"c:\folder1\test.jpg",

4)Tried with - selenium.captureScreenshot("\test.png"); and it works fine but it does not solve my purpose and I dont want to use awt.

Can someone please suggest what could be wrong?

Thanks,
Mugen

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

溺孤伤于心 2024-08-11 05:20:32

更好的是......

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

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 发送到方法则使用当前时间。

Better yet...

I ran into a similar issue, where I only had access to a relative path instead of an absolute one. Here is the solution I came up with:

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(), "");
}

Which will put a screen shot of the entire page into the reports directory that is relative to the project. I am using the method name as the file name, or the current time if null is sent to the method.

鸩远一方 2024-08-11 05:20:32

试试这个:

String path = System.getProperty("user.dir");
selenium.captureEntirePageScreenshot(path + "\\test.png", "");

Try this:

String path = System.getProperty("user.dir");
selenium.captureEntirePageScreenshot(path + "\\test.png", "");
不交电费瞎发啥光 2024-08-11 05:20:32

对于任何可能涉及的人来说。在我继续摆弄代码一段时间并重新启动系统后,问题得到解决。我开始知道 captureEntirePageScreenshot 仅适用于绝对路径,因此我确保我一直在尝试这一点。

To whomsoever it may concern,. the problem was solved after I kept fiddling with the code for a while and restarted my system. I came to know that captureEntirePageScreenshot works only on absolute paths so I made sure I kept trying with just that.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文