我正在使用 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)用“background=#CCFFDD”替换“”(字符串kwargs参数)
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。
有人可以建议可能出了什么问题吗?
Thanks,
Mugen
更好的是...
我遇到了类似的问题,我只能访问相对路径而不是绝对路径。这是我想出的解决方案:
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 发送到方法则使用当前时间。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)