来自Cukes Google Group 的交叉发布:
我尝试了多种保存屏幕截图的方法,但最终选择了内置于 watir-webdriver 中的方法。无论我使用哪种方法,我都无法在 Cucumber HTML 报告中成功嵌入指向该图像的链接。
在 c:\ruby\cucumber\project_name\features\support\hooks.rb 中,我正在使用:
After do |scenario|
if scenario.failed?
@browser.driver.save_screenshot("screenshot.png")
embed("screenshot.png", "image/png")
end
end
带有文本“屏幕截图”的链接已添加到报告中,但 URL 是项目目录路径("c:\ruby\cucumber\project_name")
,而不是文件的直接链接("c:\ruby\cucumber\project_name\screenshot.png")
。我使用 Dir.pwd 尝试了许多不同的图像格式和直接路径,每次都得到相同的结果。
我错过了什么?
谢谢
Windows XP Ruby 1.8.7 watir-webdriver (0.2.4) 黄瓜 (0.10.3)