2
votes

I'm currently using Cucumber Framework with Selenium Java . I wish to upgrade my Normal Cucumber reports to extent reports . Tried with Extent reports 3.0.2. I was able to generate Extent reports but i was not able to embed Screenshot of failed test cases into Extent Report .

Can any one please help to know is this possible to have this feature of embedding screenshot for failed cases into Cucumber Selenium Java Framework . If yes please help me in forwarding any link related to this or code .

also i would like to understand is there any other Custom reports better than extent report which is easier to configure .

Also please help me in understanding which sort of paralell execution is faster . 1.Cucumber JVM paralell plugin 2.Maven Sure fire plugin 3.Test NG paralell classes

also it would be great help if any one can share me on how to configure for parallel execution .

thanks for help in advance . Have nice day

3
Add the code. Consider splitting the questions. - Grasshopper

3 Answers

1
votes

Use something similar to this in order to have extent report take screenshots when ever failure occurs.Good luck.

public void onTestFailure(ITestResult testResult) {
        System.out.println("Method " + getTestMethodName(testResult) + " failed");
        watch.reset();
        try {
            String path = TakeScreenshot.takeScreenshot(eDriver, testResult.getMethod().getMethodName());
            test.addScreenCaptureFromPath(path).fail("<b>"
                    + testResult.getMethod().getMethodName().replaceAll("(\\p{Ll})(\\p{Lu})", "$1 $2").toUpperCase()
                    + "</b>" + " failed <br>"+testResult.getThrowable());

        } catch (IOException e) {
            e.printStackTrace();
        }

    }
1
votes

If you can add the plugin in your runner class

plugin = { "com.cucumber.listener.ExtentCucumberFormatter:Report/Report.html"},

Try this one to error while taking screenshot.. And it could add screenshots of a failed test case in Cucumber extent report.

public void forAfterScen(Scenario scenario) throws IOException
    {
        if (scenario.isFailed()) {
            String screenshotName = scenario.getName().replaceAll(" ", "_");
            try {
                TakesScreenshot ts = (TakesScreenshot) driver;
                File sourcePath = ts.getScreenshotAs(OutputType.FILE);

                File destinationPath = new File(System.getProperty("user.dir") + "\\Report\\" + screenshotName+".png");

                Files.copy(sourcePath, destinationPath);   

                Reporter.addScreenCaptureFromPath(destinationPath.toString());
                Reporter.addScenarioLog(screenshotName);
            } catch (IOException e) {
            } 
        }
    }
0
votes

I use the following NPM module which I have to manually run after each test, because I too am running in java...unless there is java code that can run a node module programmatically, that I don't know about - cucumber-html-reporter