Hi sir,
I have created a method in a class to send html report through email.
I'm calling that method inside @Aftertest. So that the method should run after all the test methods are executed.
Once all the tests are executed, @Aftertest Method will execute and i will receive the html report.
But the issue is, it is not sending the latest html report. It is sending a previous html report.
Below is the code snippet
DemoTest class
Public static void Demoemail()
{
System.out.println("before report sending");
EmailAttachment attachment = new EmailAttachment();
attachment.setPath("D:\\Test\\test-output\\emailable-report.html");
attachment.setDisposition(EmailAttachment.ATTACHMENT);
attachment.setDescription("Report QA automation report");
attachment.setName("Report QA");
MultiPartEmail email1 = new MultiPartEmail();
Email email = new SimpleEmail();
email1.setHostName("
smtp.gmail.com");
email1.setSmtpPort(465);
email1.setAuthenticator(new DefaultAuthenticator("
tes...@gmail.com", "pass23mds"));
email1.setSSLOnConnect(true);
email1.setFrom("
tes...@gmail.com");
email1.setSubject("Test Automation report");
email1.setMsg("Sending email through selenium");
email1.addTo("
asd...@gmail.com");
email1.attach(attachment);
email1.send();
System.out.println("Report sent");
}
in Test Class
{
@ Test
{}
@AfterTest
{
DemoTest. Demoemail();
}
}
Thanks,
Akshaya