MainMenu

Home Java Overview Maven Tutorials

Tuesday, 6 February 2018

Send Reports Automatically to Email using Maven from Eclipse




Hell Friends,

In this article we will discuss

How to Send Reports Automatically to Email using Maven from Eclipse by Post-Man plugin



For Video :

Click here

This is very simple, you just need to add some plugin & remaining things will be same.
So steps will be as below :
Step 1 : Create a Maven Project.
Step 2 : Add Dependency as below in your POM.xml file.
Step 3 : Update the project.
Step 4 : Convert your Execution file to TestNG xml file & place it in main source folder(if using below plugins).
Step 5 : Set email address & report path.
Step 6 : Now Run your POM.xml file.

To Download the complete plugin in notepad click the below link :

click here



Alternatively, one can copy the below plugin & paste in his Maven Pom.xml file.

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>Report_demo</groupId>
<artifactId>Report_demo</artifactId>
<version>0.0.1-SNAPSHOT</version>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<suiteXmlFile>src/main/resources/testng.xml</suiteXmlFile>
</properties>
<dependencies>
<dependency>
<groupId>com.relevantcodes</groupId>
<artifactId>extentreports</artifactId>
<version>2.41.1</version>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.8</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java -->
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.6.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.poi/poi -->
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>3.17</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.20.1</version>
<configuration>
<suiteXmlFiles>
<suiteXmlFile>${suiteXmlFile}</suiteXmlFile>
</suiteXmlFiles>
</configuration>
</plugin>
<plugin>
<groupId>ch.fortysix</groupId>
<artifactId>
maven-postman-plugin</artifactId>
<executions>
<execution>
<id>send a mail</id>
<phase>test</phase>
<goals>
<goal>send-mail</goal>
</goals>
<inherited>true</inherited>
<configuration>
<!-- From Email address -->
<from>cchauhan281188@gmail.com</from>
<!-- Email subject -->
<subject>Test Automation Report</subject>
<!-- Fail the build if the mail doesnt reach -->
<failonerror>true</failonerror>
<!-- host -->
<mailhost>smtp.gmail.com</mailhost>
<!-- port of the host -->
<mailport>465</mailport>
<mailssl>true</mailssl>
<mailAltConfig>true</mailAltConfig>
<!-- Email Authentication(USername and Password) -->
<mailuser>Enter email id here</mailuser>
<mailpassword>Enter password here</mailpassword>
<receivers>
<!-- To Email address -->
<receiver>cchauhan32@gmail.com</receiver>
</receivers>
<fileSets>
<fileSet>
<!-- Report directory Path -->
<directory>C://workspace//SendMavenEmail//Reports</directory>
<directory>E://java_oxygen//Report_demo//Reports</directory>
<includes>
<!-- Report file name -->
<include>TestReport.html</include>
</includes>
<!-- Use Regular Expressions like **/*.html if you want all the html files to send-->
</fileSet>
</fileSets>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>



Here is the sample code

package com.lang.Execution;
import java.io.IOException;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;
import com.relevantcodes.extentreports.ExtentReports;
import com.relevantcodes.extentreports.ExtentTest;
import com.relevantcodes.extentreports.LogStatus;
public class ReportTest
{
WebDriver driver;
ExtentReports report;
ExtentTest logger;
@BeforeTest
public void navigate() throws InterruptedException, IOException
{
System.setProperty("webdriver.chrome.driver", "D:\\Selenium\\Complete selenium\\ChromeDriver\\chromedriver.exe");
driver=new ChromeDriver();
driver.manage().window().maximize();
driver.navigate().to("http://www.way2testing.com");
Thread.sleep(3000);
report=new ExtentReports("./Reports/TestReport.html");
}
@Test(priority = 0)
public void title()
{
logger=report.startTest("Verifytitle");
logger.log(LogStatus.INFO, "test started ");
System.out.println("Your Title is :" + driver.getTitle());
String title = driver.getTitle();
if(title.equalsIgnoreCase(" Online Software Testing: Software Testing"))
{
logger.log(LogStatus.PASS, "Test Verified");
}
else
{
logger.log(LogStatus.FAIL, "Test Failed");
}
report.endTest(logger);
//Flush the data to report
report.flush();
}
@Test(priority = 1)
public void clicklink(){
//Create object for Report with filepath
//report=new ExtentReports("./Reports/TestReport.html");
//Start the test
logger=report.startTest("Verifylink");
//Log the status in report
logger.log(LogStatus.INFO, "Test started ");
driver.findElement(By.xpath(".//*[@id='post-body-751561208295527719']/div[1]/table/tbody/tr[6]/td[1]/a/img")).click();
//Pass the test in report
logger.log(LogStatus.PASS, "Link Verified");
//End the test
report.endTest(logger);
//Flush the data to report
report.flush();
}
}







Tags :

how to send report through email in selenium webdriver,Sending Selenium Reports through mail,
Advance Selenium Reporting- Selenium Webdriver tutorial How to Send a Report via Email in selenium,
How to generate and send HTML reports using Selenium WebDriverSend Reports Automatically to Email using Maven from Eclipse
Robotically Send Test Reports via Mail Using Maven Postman PluginHow to send Test result to email using maven by postman plugin
how do i send a email test report from maven,How to send an automated email with test reports using Maven and TestNG,

42 comments:

  1. How to Send Reports Automatically to Email using Maven from Eclipse by Post-Man plugin for negative test cases

    ReplyDelete
  2. This is really a nice and informative, containing all information and also has a great impact on the new technology. Thanks for sharing it Email Database

    ReplyDelete
  3. After you have identified your market you are now ready to make your first communication with them. Email List

    ReplyDelete
  4. Impressive web site, Distinguished feedback that I can tackle. Im moving forward and may apply to my current job as a pet sitter, which is very enjoyable, but I need to additional expand. Regards. Workflow Management

    ReplyDelete
  5. Thanks For sharing this Superb article.I use this Article to show my assignment in college.it is useful For me Great Work. email list

    ReplyDelete
  6. i really like this article please keep it up.
    business email

    ReplyDelete
  7. I was reading some of your content on this website and I conceive this internet site is really informative ! Keep on putting up. como abrir correo hotmail

    ReplyDelete
  8. Thanks for the blog loaded with so many information. Stopping by your blog helped me to get what I was looking for. fraud detection

    ReplyDelete
  9. Great job for publishing such a beneficial web site. Your web log isn’t only useful but it is additionally really creative too. www.hotmail.com entrar

    ReplyDelete
  10. hello!! Very interesting discussion glad that I came across such informative post. Keep up the good work friend. Glad to be part of your net community. Search Engine Scraper Bot

    ReplyDelete
  11. I really thank you for the valuable info on this great subject and look forward to more great posts. Thanks a lot for enjoying this beauty article with me. I am appreciating it very much! Looking forward to another great article. Good luck to the author! All the best! Facebook Groups Scraper

    ReplyDelete
  12. A committed group is fundamental to join different marketing systems. https://marketbusinessnews.com/social-media-panels-2020/242030/

    ReplyDelete
  13. Nice blog and absolutely outstanding. You can do something much better but i still say this perfect.Keep trying for the best. wiflix

    ReplyDelete
  14. I have read all the comments and suggestions posted by the visitors for this article are very fine,We will wait for your next article so only.Thanks! ECBA certification

    ReplyDelete
  15. Great job for publishing such a beneficial web site. Your web log isn’t only useful but it is additionally really creative too. best email extractor tools

    ReplyDelete
  16. Admiring the time and effort you put into your blog and detailed information you offer!.. pst email extractor

    ReplyDelete
  17. Whenever I have some free time, I visit blogs to get some useful info. Today, I found your blog with the help of Google. Believe me; I found it one of the most informative blog. send email to 1000 recipients

    ReplyDelete
  18. What a thrilling post, you have pointed out some excellent points, I as well believe this is a superb website. I have planned to visit it again and again. bulk email service provider

    ReplyDelete
  19. Select In Features-Unfortunately, there could be the point at which your contact is not, at this point inspired by your offers or business. The individual in question ought to have a choice to leave your program. how to make a group email list on ipad

    ReplyDelete
  20. Much the same as some other "fight", the more hopefuls you have playing, the harder the opposition will be.Lead generation

    ReplyDelete
  21. Incorporating social media into your site is simple. There are destinations that give the code and symbols to you to just glue into your web structure. When you are using social media ensure you show it SMM Panel

    ReplyDelete
  22. Superior post, keep up with this exceptional work. It's nice to know that this topic is being also covered on this web site so cheers for taking the time to discuss this! Thanks again and again! one funnel away challenge

    ReplyDelete
  23. Im no expert, but I believe you just made an excellent point. You certainly fully understand what youre speaking about, and I can truly get behind that. sketch.

    ReplyDelete
  24. Thanks so much for this information. I have to let you know I concur on several of the points you make here and others may require some further review, but I can see your viewpoint. Create your Own Expert Advisor

    ReplyDelete
  25. Keep up the wonderful piece of work, I read few posts on this internet site and I think that your blog is really interesting and holds bands of fantastic information. CheapSoft4you

    ReplyDelete
  26. I wrote about a similar issue, I give you the link to my site. Website design London

    ReplyDelete
  27. Thank you for very usefull information.. OrbitEx

    ReplyDelete
  28. You there, this is really good post here. Thanks for taking the time to post such valuable information. Quality content is what always gets the visitors coming. ray ban eyeglasses

    ReplyDelete
  29. It is hard to pinpoint which of these free online marketing apparatuses work and which don't however advancement in any structure can't be terrible, so I invest a little energy on each. SEO

    ReplyDelete
  30. Keep up the wonderful piece of work, I read few posts on this internet site and I think that your blog is really interesting and holds bands of fantastic information. 먹튀검증

    ReplyDelete
  31. You have under 10 seconds to persuade a site guest to stay adequately long to find out about the nature of your administrations, your items or your message. Web surfers are spiked out on data over-burden. Webdesign

    ReplyDelete
  32. I heard about the 5 qualities that make a name awesome from this product naming agency? I heard a lot of people were able to come up with various creative names because of this. what google did to me

    ReplyDelete
  33. Initial You got a awesome blog .I determination be involved in plus uniform minutes. i view you got truly very functional matters , i determination be always checking your blog blesss. why not try here

    ReplyDelete
  34. In today’s society, naming your brand is a difficult, but necessary task. However, when I enrolled this course, I found myself entertained and informed enough to start naming my brand.  Email Harvester

    ReplyDelete
  35. Hey i’m for the first time here. I came across this board and I find It seriously helpful & it helped me out much. I hope to give something back and aid others as you aided me. Ssndob

    ReplyDelete
  36. As far as me being a member here, I wasn’t aware that I was a member for any days, actually. When the article was published I received a notification, so that I could participate in the discussion of the post, That would explain me stumbuling upon this post. But we’re certainly all members in the world of ideas. e waste problems

    ReplyDelete
  37. Deciding on a brand name is one of the common mistakes of startup companies. Having names that is thoroughly thought off is an edge that can lead your company to success. Email Extractor

    ReplyDelete
  38. It is a natural method of streamlining your online substance to improve the positioning of your site on the web crawler. SEO Limburg

    ReplyDelete
  39. As I was sitting on a rock in India, looking over the city of New Delhi, contemplating on my next decision, I was chastened to submit my thoughts and passion about money unto the world. Capitalism shall grow in abundance; the entire economic system of our world is impossible without credit. Our entire civilization is based on money, from Babylon, to New York City. The hope of our time is based off the fact that Rachel will control the world through her music and love. She shall reign like a queen over billions and billions, and I shall support her by contemplating my next decision looking off to the distance, because this, this is how I receive revelation, with the common interest of money and overseas trades that the world depends on. MecSoft RhinoCAM 2018 Build 8.0.28 for Rhino 6 sale

    ReplyDelete
  40. Thanks for every other informative site. The place else may just I get that kind of information written in such an ideal means? I have a venture that I’m just now operating on, and I have been on the look out for such information. quenza software

    ReplyDelete
  41. After arriving at this level, we likewise need to set up our general public for harmony, and to ensure the harmony, innovation should be modified to cultivate the approach of war.TutuApp web

    ReplyDelete