黄瓜覆盖率报告-如何向每个黄瓜步骤添加屏幕截图

时间:2019-09-17 11:55:07

标签: selenium-webdriver cucumber extentreports

我无法在执行“黄瓜覆盖率”报告的每个步骤中添加屏幕截图。请参见下面的代码段。

public String captureScreenshotMobileWeb(WebDriver driver, String screenShotName) {
    TestLogger tLog = new TestLogger();
    String logFilename = (new SimpleDateFormat("yyyyMMddHHmmsss")).format(new Date());

    try {
        Object ts;
        if (driver.equals(this.wdriver)) {
            ts = this.wdriver;
        } else {
            ts = (TakesScreenshot)driver;
        }
        File source = (File) ((TakesScreenshot)ts).getScreenshotAs(OutputType.FILE);
        String dest = "C:\\Users\\nb313260\\Documents\\Projects\\Servicing\\staff-servicing-automation-test\\ScreenShots\\" + screenShotName + "_" + logFilename + ".png";
        File destination = new File(dest);
        FileUtils.copyFile(source, destination);
        tLog.logInfo("Screenshot taken: " + screenShotName);
        return dest;
    } catch (Exception var9) {
        tLog.logError(var9.getMessage());
        return var9.getMessage();
    }
}

功能:

    Feature: Account overview display for all product types 
Scenario Outline: As a user I must be able to view account details Given Client is authenticated 
When User launches staff servicing with Account number "<Account_Number>" for "<Product_Type>" 
Then User must be able to view account overview page and details under At a glance, Spotlight & Account information for selected "<Account_Number>" account number on screen Examples: |Account_Number|Product_Type|

0 个答案:

没有答案