我在Jasmine中的每个测试描述都附带一个afterEach()
来检查测试用例是否通过。如果它没有通过,我想截取违规测试屏幕的截图。
有时我会收到崩溃报告错误。我不确定如何调试或修复它以了解更多信息。
afterEach(function() {
var passed = jasmine.getEnv().currentSpec.results().passed();
if (!passed) {
takeScreenCap("FAILEDTESTCASE_" + jasmine.getEnv().currentSpec.description);
}
});
崩溃本身
Message:
UnknownError: unknown error: cannot take screenshot
from unknown error: Failed to capture tab: unknown error
JavaScript stack:
Error: Failed to capture tab: unknown error
at checkForExtensionError (chrome-extension://aapnijgdinlhnhlmodcfapnahmbfebeb/background.js:14:17)
at Object.callback (chrome-extension://aapnijgdinlhnhlmodcfapnahmbfebeb/background.js:37:5)
at safeCallbackApply (extensions::sendRequest:21:15)
at handleResponse (extensions::sendRequest:72:7)
(Session info: chrome=44.0.2403.89)
(Driver info: chromedriver=2.15.322455 (ae8db840dac8d0c453355d3d922c91adfb61df8f),platform=Mac OS X 10.10.4 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 27 milliseconds
Build info: version: '2.45.0', revision: '5017cb8', time: '2015-02-26 23:59:50'
System info: host: 'Pro.local', ip: '', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.10.4', java.version: '1.8.0_45'
Driver info: org.openqa.selenium.chrome.ChromeDriver
Capabilities [{applicationCacheEnabled=false, rotatable=false, mobileEmulationEnabled=false, chrome={userDataDir=/var/folders/92/10bfp2jx43n468ctgft30gr40000gn/T/.org.chromium.Chromium.KRpAWe}, takesHeapSnapshot=true, databaseEnabled=false, handlesAlerts=true, version=44.0.2403.89, platform=MAC, browserConnectionEnabled=false, nativeEvents=true, acceptSslCerts=true, locationContextEnabled=true, webStorageEnabled=true, browserName=chrome, takesScreenshot=true, javascriptEnabled=true, cssSelectorsEnabled=true}]
Session ID: 53788da31ca3dbf09e6b9f80525403d9
Stacktrace:
UnknownError: unknown error: cannot take screenshot
from unknown error: Failed to capture tab: unknown error
JavaScript stack:
Error: Failed to capture tab: unknown error
at checkForExtensionError (chrome-extension://aapnijgdinlhnhlmodcfapnahmbfebeb/background.js:14:17)
at Object.callback (chrome-extension://aapnijgdinlhnhlmodcfapnahmbfebeb/background.js:37:5)
at safeCallbackApply (extensions::sendRequest:21:15)
at handleResponse (extensions::sendRequest:72:7)
(Session info: chrome=44.0.2403.89)
(Driver info: chromedriver=2.15.322455 (ae8db840dac8d0c453355d3d922c91adfb61df8f),platform=Mac OS X 10.10.4 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 27 milliseconds
Build info: version: '2.45.0', revision: '5017cb8', time: '2015-02-26 23:59:50'
System info: host: 'Pro.local', ip: '...', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.10.4', java.version: '1.8.0_45'
Driver info: org.openqa.selenium.chrome.ChromeDriver
Capabilities [{applicationCacheEnabled=false, rotatable=false, mobileEmulationEnabled=false, chrome={userDataDir=/var/folders/92/10bfp2jx43n468ctgft30gr40000gn/T/.org.chromium.Chromium.KRpAWe}, takesHeapSnapshot=true, databaseEnabled=false, handlesAlerts=true, version=44.0.2403.89, platform=MAC, browserConnectionEnabled=false, nativeEvents=true, acceptSslCerts=true, locationContextEnabled=true, webStorageEnabled=true, browserName=chrome, takesScreenshot=true, javascriptEnabled=true, cssSelectorsEnabled=true}]
Session ID: 53788da31ca3dbf09e6b9f80525403d9
at Array.forEach (native)
From: Task: Asynchronous test function: afterEach()
Error
答案 0 :(得分:1)
我不会重新发明轮子并使用:
protractor-html-screenshot-reporter
(对于jasmine1)protractor-jasmine2-screenshot-reporter
(对于jasmine2)它会为您提供包含屏幕截图的精美HTML报告。如果您想要针对失败制作屏幕截图,请将captureOnlyFailedSpecs
设置为true
:
jasmine.getEnv().addReporter(new HtmlScreenshotReporter({
captureOnlyFailedSpecs: true
}));