Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/xslt/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何在刷新项目后在eclips中存储或显示扩展报告,同时在所述驱动器上_Java_Eclipse_Selenium - Fatal编程技术网

Java 如何在刷新项目后在eclips中存储或显示扩展报告,同时在所述驱动器上

Java 如何在刷新项目后在eclips中存储或显示扩展报告,同时在所述驱动器上,java,eclipse,selenium,Java,Eclipse,Selenium,同时,我想在eclipse窗口(刷新项目后出现)上显示一个扩展报告,并使用selenium webdriver(selenium webdriver)显示所提到的驱动程序(例如:d:/project name/…),您可能希望在驱动器/文件夹d:/project name/…中创建报告 // start reporters ExtentHtmlReporter htmlReporter = new ExtentHtmlReporter("d://testproject/exte

同时,我想在eclipse窗口(刷新项目后出现)上显示一个扩展报告,并使用selenium webdriver(selenium webdriver)显示所提到的驱动程序(例如:d:/project name/…),您可能希望在驱动器/文件夹d:/project name/…中创建报告

     // start reporters
    ExtentHtmlReporter htmlReporter = new ExtentHtmlReporter("d://testproject/extent.html");

    // create ExtentReports and attach reporter(s)
    ExtentReports extent = new ExtentReports();
    extent.attachReporter(htmlReporter);

这将在文件夹/drive
d://testproject
中创建数据块报告。我假设这里的项目名称是testproject。

这是我的Extend report@BeforeTest方法

@BeforeTest
public void setUp1() {
    // where we need to generate the report
    String fileName = new SimpleDateFormat("dd-MM-yyyy").format(new Date());
    htmlReporter = new ExtentHtmlReporter("C:/xampp/htdocs/Automation_report/files/summerrentals/summerrentals("+fileName+").html");
    extent = new ExtentReports();
    extent.attachReporter(htmlReporter);

    // Set our document title, theme etc..
    htmlReporter.config().setDocumentTitle("Testing");
    htmlReporter.config().setReportName("Testing");
    htmlReporter.config().setTestViewChartLocation(ChartLocation.TOP);
    htmlReporter.config().setTheme(Theme.DARK);
}
这是附加屏幕截图的后续方法

@AfterMethod
    public void setTestResult(ITestResult result) throws IOException {

        String screenShot = CaptureScreenShot.captureScreen(wd, CaptureScreenShot.generateFileName(result));

        if (result.getStatus() == ITestResult.FAILURE) {
            test.log(Status.FAIL, result.getName());
            test.log(Status.FAIL,result.getThrowable());
            test.fail("Screen Shot : " + test.addScreenCaptureFromPath(screenShot));
        } else if (result.getStatus() == ITestResult.SUCCESS) {
            test.log(Status.PASS, result.getName());
            test.pass("Screen Shot : " + test.addScreenCaptureFromPath(screenShot));
        } else if (result.getStatus() == ITestResult.SKIP) {
            test.skip("Test Case : " + result.getName() + " has been skipped");
        }

        extent.flush();
        wd.quit();
    }
 public class CaptureScreenShot {
                private static final DateFormat dateFormat = new SimpleDateFormat("yyyy_MM_dd SSS");

                public static String captureScreen(WebDriver driver, String screenName) throws IOException{

                    TakesScreenshot screen = (TakesScreenshot) driver;
                    File src = screen.getScreenshotAs(OutputType.FILE);

                    String dest ="C:/xampp//htdocs/Automation_report/Test-ScreenShots"+screenName+".png";

                    File target = new File(dest);
                    FileUtils.copyFile(src, target);

                    return dest;
                }

                public static String generateFileName(ITestResult result){
                    Date date = new Date();
                    String fileName = result.getName()+ "_" + dateFormat.format(date);
                    return fileName;

                }
            }
这是我拍摄截图的截图课程

@AfterMethod
    public void setTestResult(ITestResult result) throws IOException {

        String screenShot = CaptureScreenShot.captureScreen(wd, CaptureScreenShot.generateFileName(result));

        if (result.getStatus() == ITestResult.FAILURE) {
            test.log(Status.FAIL, result.getName());
            test.log(Status.FAIL,result.getThrowable());
            test.fail("Screen Shot : " + test.addScreenCaptureFromPath(screenShot));
        } else if (result.getStatus() == ITestResult.SUCCESS) {
            test.log(Status.PASS, result.getName());
            test.pass("Screen Shot : " + test.addScreenCaptureFromPath(screenShot));
        } else if (result.getStatus() == ITestResult.SKIP) {
            test.skip("Test Case : " + result.getName() + " has been skipped");
        }

        extent.flush();
        wd.quit();
    }
 public class CaptureScreenShot {
                private static final DateFormat dateFormat = new SimpleDateFormat("yyyy_MM_dd SSS");

                public static String captureScreen(WebDriver driver, String screenName) throws IOException{

                    TakesScreenshot screen = (TakesScreenshot) driver;
                    File src = screen.getScreenshotAs(OutputType.FILE);

                    String dest ="C:/xampp//htdocs/Automation_report/Test-ScreenShots"+screenName+".png";

                    File target = new File(dest);
                    FileUtils.copyFile(src, target);

                    return dest;
                }

                public static String generateFileName(ITestResult result){
                    Date date = new Date();
                    String fileName = result.getName()+ "_" + dateFormat.format(date);
                    return fileName;

                }
            }
希望对你有帮助


你能详细说明你想要什么和你为此做了什么吗?我想在eclips窗口上显示扩展报告,这是在刷新我们的项目之后出现的。此外,我希望相同的(扩展报告)驱动器中提到的代码。我想在eclipse窗口和提到的驱动程序上显示相同的扩展报告