使用Selenium IDE Firefox插件的屏幕截图

时间:2014-03-10 12:25:59

标签: selenium firefox-addon screenshot

使用Selenium IDE Firefox插件,我想采用自动截图。 测试脚本包含两行:

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 个答案:

答案 0 :(得分:10)

正确设置文件路径解决了它。路径需要设置如下:

(视窗:)

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

(Linux操作系统:)

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

在此示例中,必须存在“屏幕截图”文件夹。