Thursday, July 20, 2017

How to email Selenium results reports using Jenkins?

In the previous post we have seen sending an e-mail notification when the build/tests failed. That email notification doesn’t provide us with details of Passed/Failed tests.

To get full details about the execution results, we have to use Email Extension Plugin in Jenkins.We can email the results reports that are generated in Jenkins. With which you can directly check how many tests Passed? How many failed?

I have taken three simple testng tests as shown in the below screen shot. Two of them will Pass and the other one fails.

When executed the above tests using TestN a result report "emailable-report.html" is generated under test-output folder in project home directory as show below.

Now we have to email this report from Jenkins to all the team members after test execution. Let’s get with no further due…

If you have any queries on creating testng tests and batch file please refer my previous post How to execute Selenium Test Cases from Command Prompt in TestNG?

Step 1: Installing Email Extension Plugin. Launch Jenkins-> click Manage Jenkins-> click on Install Plugins.

Step 2: In the Plugins Manager, Under Available tab-> Search for Email Extension-> Select Email Extension Plugin and click on Install without restart.

Wait for plugin to get installed for few minutes. After Installation the plugin should be available under Installed tab.

Step 3: Once the plugin installed. You need configure email in two sections Extended E-mail Notification and E-mail Notification.

Go to Mange Jenkins-> Configure System. Please enter your details as shown in the below screen shots. In the both places you need to enter same email id and password.

And from this account the emails will be sent. In my case from "" the emails will be sent.

Step 4: Now create Job to run the tests. Manage Jenkins-> New Item-> Enter Project title emailReportsDemo-> Click OK.

Step 5: Configure the tests that needs be executed.  Enter project home directory in Use custom workspace and batch file name in the Build section as shown below.

Step 6: Go to Post Build Actions and select Editable Email Notification. This option only available if Email Extension Plugin installed.

Step 7: Under Editable Email Notification section enter Recipients emails, select Content type and Click on Apply.

Step 8: Click on the Advenced Settings... button. And select Always option from Add Trigger drop down list. Which means Jenkins will trigger email every time the tests executed.

Step 9: To attach the content of the report "emailable-report.html" in the email body add the below code in "Pre-send Script" field. The below code gets the path of the report and it's content.

           def reportPath = build.getWorkspace().child("test-output/emailable-report.html")
           msg.setContent(reportPath.readToString(), "text/html");

Step 10: Click Apply and Save. We are don with configuration of Email and Tests in Jenkins. Now click on Build Now in the job created.

 Check whether emails are received or not with reports in the email body.

That's it guys, we did it. Hope this post is helpful to you, please share it with your friends. Thanks!!

#HappyLearning #HappyTesting


  1. Brother i need configuration of selenium webdriver with python and jenkins.
    means after my selenium script run email should be sent to my email address can you write a blog on this

    1. What you want to send in email? Did you try configuring email? facing issues?

  2. Hi, thank you for this explanation. I have an issue however with the emailable-report.html that is being sent. It is the previous test run result. I cannot figure out right now why this is happening. Any ideas you can offer?

    1. Update: ok so I changed my report path to be: target/surefire-reports/emailable-report.html but I'm not sure if that was the issue because I believe I had tried that path before. Its working now however. Perhaps the problem was due to having the testNG.xml report open while executing tests? not sure but its working ;)

  3. Hi,
    For me build.getWorkspace().child("test-output/emailable-report.html") path is pointing to C:\Program Files (x86)\Jenkins\workspace\project folder.
    But inside floder doesn't have any files/folders.

    Can you please help on this

    1. This comment has been removed by the author.

    2. I had the same problem
      You should set your custom workspace
      Go to configuration of your job
      Build section
      Click on the "Advanced" button
      Set "Use custom workspace" ckrckbox
      Set path to your project folder

      see screenshot

  4. This comment has been removed by the author.

  5. Hi Venkat, I tried with outlook, but no success. Do I need to change the configuration for outlook different than gmail?

    1. Yes you have to. Sorry for the late reply.

    2. Hi i have done the same configuration,it is running in the jenkins but chrome browser will not opened it will be running in background or headless like browser

  6. Hi.. I am using editable email plugin and I have custom HTML report to send. But the issue I am facing is that the html content lack the styling when I email it. Not sure how to resolve the issue.

  7. Third party processors are used and various technologies applied to identify dead or closed email accounts without sending any mails to verification

  8. If you are not working on building your email list already, then stick with this article till the end because I'm going to share 16 ways to grow your email list.
    email fraud Huntington Beach

  9. Hey, this day is too much good for me, since this time I am reading this enormous informative article here at my home. Thanks a lot for massive hard work. ethereum notifications

  10. If you think email verification is a one trick game, then you could not have been further from the cleaning

  11. This is a great inspiring article.I am pretty much pleased with your good work.You put really very helpful information. Keep it up. Keep blogging. Looking to reading your next post.

  12. Thanks a lot for massive hard work , very nice article.

  13. what if i have more than one HTML, in that case how i am supposed to configure 2 customized HTML report file?

  14. So, people may notice you from videos. You can also add offers and email sign-up cards & annotations on your videos. While watching your videos people notice this annotations and cards. Email List for Marketing

  15. Thanks for sharing nice information with us. i like your post and all you share with us is uptodate and quite informative, i would like to bookmark the page so i can come here again to read you, as you have done a wonderful job. ActveCampaign Support

  16. I really appreciate this wonderful post that you have provided for us. I assure this would be beneficial for most of the people.
    email search

  17. A very awesome blog post. We are really grateful for your blog post. You will find a lot of approaches after visiting your post. como abrir correo hotmail

  18. Hi! This is my first visit to your blog! We are a team of volunteers and new initiatives in the same niche. Blog gave us useful information to work. You have done an amazing job!


Selenium4: Working with two parallel windows in Selenium Automation

A new method newWindow() is introduced in Selenium 4 (Alpha). Using this method we can open a new tab or new window from the current window...