使用Selenium IDE Firefox插件进行截图

6
使用Selenium IDE火狐插件,我想要自动截取屏幕截图。 测试脚本包含两行代码:
Command: open; Target: http://www.google.com
Command: captureEntirePageScreenshotAndWait

日志显示:
[info] Executing: |open | http://www.google.com | |
[info] Executing: |captureEntirePageScreenshotAndWait | | | 
[error] Unexpected Exception: [Exception... "Component returned failure code: 0x80520001 (NS_ERROR_FILE_UNRECOGNIZED_PATH) [nsILocalFile.initWithPath]" nsresult: "0x80520001 (NS_ERROR_FILE_UNRECOGNIZED_PATH)" location: "JS frame :: chrome://selenium-ide/content/selenium-core/scripts/selenium-api.js :: <TOP_LEVEL> :: line 3045" data: no]. toString -> function toString() { [native code] }, message -> Component returned failure code: 0x80520001 (NS_ERROR_FILE_UNRECOGNIZED_PATH) [nsILocalFile.initWithPath], result -> 2152857601, name -> NS_ERROR_FILE_UNRECOGNIZED_PATH, filename -> chrome://selenium-ide/content/selenium-core/scripts/selenium-api.js, lineNumber -> 3045, columnNumber -> 0, inner -> null, data -> null, location -> JS frame :: chrome://selenium-ide/content/selenium-core/scripts/selenium-api.js :: <TOP_LEVEL> :: line 3045

如何获取截图?
1个回答

10

正确设置文件路径解决了这个问题。路径需要按如下方式设置:

(Windows:)

Command: captureEntirePageScreenshotAndWait; Target: D:\\Screenshots\\test.png

(Linux:)

Command: captureEntirePageScreenshotAndWait; Target: \\Screenshots\\test.png

在这个例子中,文件夹“Screenshots”必须存在。


Linux目标似乎不正确。我相信Linux使用正斜杠“/”而不是反斜杠。 - mdzeko
1
@mdzeko 我敢打赌Selenium使用一种启发式方法转换斜线。甚至在Windows上,你可能也可以使用/而不是\\ - jpaugh
@mdzeko 我只是猜测...我知道Java的ant和许多其他工具可以做到这一点。如果你测试过了,请告诉我。谢谢! - jpaugh

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接