当场景失败时,我目前对快照有以下实现 -
@After("@destroy")
public void tearDown(Scenario scenario) throws Throwable {
try {
if (scenario.isFailed()) {
final byte[] screenshot = ((TakesScreenshot) driverC).getScreenshotAs(OutputType.BYTES);
scenario.embed(screenshot, "image/png");
/*
* final File screenshot = ((TakesScreenshot)
* driverC).getScreenshotAs(OutputType.FILE);
* FileUtils.copyFileToDirectory(screenshot, new
* File("/home/ninad/eclipse-workspace/Reports/html"));
*/
}
} catch (WebDriverException somePlatformsDontSupportScreenshots) {
System.err.println(somePlatformsDontSupportScreenshots.getMessage());
} finally {
driverC.close();
}
}
这些是我的情景 -
Scenario: Filter Airline with Dropdowns
Given element with id "at-offloadsreceived" is displayed
When I select option "string:OMA" from dropdown "at-usrAirlineDropDown"
And I click element with id "at-filterBtn"
Then element with id "at-hdr-tailsign" is displayed
And element with id "at-link-tailsign-20" is displayed
@destroy
Scenario: Navigate to Home and Shutdown
Given I am on the "/#/ted/home" page
Then element with id "landing_header" is displayed
我看到了不同的问题:
不会拍摄任何快照,然后进行嵌入。
如果在具有@destroy标记的方案中发生错误,则将拍摄快照,但在上一个方案中,如果出现错误,则不会拍摄快照。
任何帮助将不胜感激。仅供参考 - 我是新手,所以一步一步的指示是最好的! :)