0

While running a test case, I have a try/catch mechanism and an onevent listener that produces a screenshot if an error/failure occurs. Can I also compose and email and attach that screenshot there and send it to someone?

Kaloyan Roussev
  • 14,515
  • 21
  • 98
  • 180

3 Answers3

5

There is nothing to do with selenium here, You have to Check this link and override the attachment file with your Screenshot file.

Community
  • 1
  • 1
Karthikeyan
  • 2,634
  • 5
  • 30
  • 51
0

This is more of a job for whatever is running your integration tests. Typically one runs integration tests on some kind of Continuous Integration environment, such as Jenkins. Your CI environment should support emails/notification of failing tests.

Qwerky
  • 18,217
  • 6
  • 44
  • 80
0

Yes. If you are using a linux box for executing your selenium test cases, you can install mutt, a CLI mail client to send mail with attachments. Also, there is JavaMail API that you can use. JavaMail API example

If you want to use mutt, first install mutt. Then create a file .muttrc in your home folder and include the following parameters for e.g:

set smtp_url = "smtp://your_id@domain.com@smtp.gmail.com:587"
set smtp_pass = "password"
set realname = "Foo Bar"

Example:

mutt -s "test mail" your_id@domain.com -a attachment.zip < email_body.txt

You need to include this command in a shell script and execute the script from a Java class using Runtime.getRuntime().exec(myShellScript);

Purushotham
  • 3,770
  • 29
  • 41
Abhijeet Vaikar
  • 1,578
  • 4
  • 27
  • 50