1

I am using java selenium with cucumber framework and report i an using extent properties an spark the issue which I am facing right now is my extent repot getting created after save 1 3o sec but my mailing services/hook is called before my report generated so I want solution where the creating zip file(containing reports) should be called only when the report are created i.e. after 1.30 sec.

@After
public void endTest(Scenario scenario) throws IOException, InterruptedException, AddressException, InvalidFormatException,
ParseException, MessagingException {
    if (scenario.isFailed()) {

        try {
            
            //screenshot
            File sourcePath=    ((TakesScreenshot)base.driver).getScreenshotAs(OutputType.FILE);
            byte[] fileContent = FileUtils.readFileToByteArray(sourcePath);
            scenario.attach(fileContent, "image/png", "image"); // ... and embed it in
        } catch (WebDriverException e) {
            e.printStackTrace();
        }

    } else {
        try {
            File sourcePath=    ((TakesScreenshot)base.driver).getScreenshotAs(OutputType.FILE);
            byte[] fileContent = FileUtils.readFileToByteArray(sourcePath);
            scenario.attach(fileContent, "image/png", "image"); 
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    Thread.sleep(30000);

    
    String zip = Zip.zip(new File("./Report"));

    BufferedOutputStream stream = new BufferedOutputStream(new FileOutputStream("C:\\Project\\Contract\\Report.zip"), 10000);
    byte[] decode = Base64.getDecoder().decode(zip);
    stream.write(decode);
    stream.close();

    Thread.sleep(10000);

    Automail automail = new Automail();
    automail.Gen_Reports();
    
    Thread.sleep(30000);

    if(base.driver!=null)
    {
    base.driver.quit();
    }

0 Answers0