Search
 
 

Display results as :
 


Rechercher Advanced Search

Latest topics
» how to connect DB in selenium webriver
Fri Oct 06, 2017 4:09 pm by anbarasi

» How find any text in browser screen and click on it?
Thu Oct 05, 2017 2:02 pm by sandeepkommineni

» Selenium Webdriver
Tue Oct 03, 2017 1:35 pm by PiyushBiswas

» GRID setup tutorial.
Wed Sep 27, 2017 4:29 pm by johnyapp

» Drag & Drop Between Windows Using Selenium Driver
Wed Sep 27, 2017 2:10 pm by 26rondel

» Check if window is closed / verify input
Sat Sep 23, 2017 10:21 pm by brainstir

» How to work on pages with AJAX in selenium?
Mon Sep 18, 2017 6:08 pm by azharuddin

» pause test until user press a key like F2
Wed Aug 09, 2017 11:10 pm by djnforce

» Selecting the input for auto populating element
Sat Jul 29, 2017 7:53 pm by kdabbara

Navigation
 Portal
 Index
 Memberlist
 Profile
 FAQ
 Search

Automate sending an email in Selenium IDE

View previous topic View next topic Go down

Automate sending an email in Selenium IDE

Post by rodale_janet on Fri Mar 07, 2014 10:49 pm

Can you send an email with the results file attached from Selenium itself or do you need to do it another way.  I have VBS code that I can modify to send an email with an attachment just do not know how to get it to execute.   Thanks!!

rodale_janet
Active particpant
Active particpant

Posts : 10
Join date : 2014-03-07

Back to top Go down

Re: Automate sending an email in Selenium IDE

Post by Adviser on Tue Jun 24, 2014 5:26 pm

HI,
 you can do it in 2 ways:

1. write the same logic of VBscript in your selenium scripting language.
2. find a way to execute a .vbs or batch file via selenium programming.

choose the either way to get a solution. google it for exact snippet.

_________________
Spread Your Knowledge About Selenium Tool.

Administrator
Email: selenium.discussion.thread@live.com
Forum: http://seleniumforum.forumotion.net
avatar
Adviser
------------------------
------------------------

Posts : 379
Join date : 2009-07-30
Location : India

http://seleniumforum.forumotion.net

Back to top Go down

Re: Automate sending an email in Selenium IDE

Post by rodale_janet on Tue Jun 24, 2014 7:09 pm

Thanks!!

I actually found something on the internet that supplied code to do it in Java.   I have a "SendMail" class that I execute if there is an error or if the test completes successfully.

rodale_janet
Active particpant
Active particpant

Posts : 10
Join date : 2014-03-07

Back to top Go down

Re: Automate sending an email in Selenium IDE

Post by saravana.s on Fri Jun 27, 2014 6:28 pm

Thanks for sharing good information. Keep posting

saravana.s

Posts : 2
Join date : 2014-06-27

Back to top Go down

Re: Automate sending an email in Selenium IDE

Post by rodale_janet on Fri Jun 27, 2014 6:36 pm

Code:
Here is the code that I found and am using.  You need to bring in the JavaMail library to your project.:
package [name of your package];

import java.util.Properties;
import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;
import javax.activation.*;

public class SendMail {
   public SendMail(String[] toMail, String subject, String msg) {
          Properties props = System.getProperties();
          props.put("mail.smtp.host", "smtp.rodale.com");
          props.put("mail.smtp.port", "25");
          Session session = Session.getDefaultInstance(props);
          try {
              Message message = new MimeMessage(session);
              message.setFrom(new InternetAddress("TestAutomation@rodale.com"));
              InternetAddress[] toAddress = new InternetAddress[toMail.length];

              for( int i = 0; i < toMail.length; i++ ) {
                   toAddress[i] = new InternetAddress(toMail[i]);
               }

               for( int i = 0; i < toAddress.length; i++) {
                   message.addRecipient(Message.RecipientType.TO, toAddress[i]);
               }

              message.setSubject(subject);
              message.setText(msg);
              Transport.send(message);
              System.out.println("Done");
          }
          catch (MessagingException ex) {
              throw new RuntimeException(ex);
          }
         
   }

}

This is how my code uses it:
private void executeSubXpath (String urlName, String menuItem, String pageTitle)
   {
      String msg = "";
                  
      wait_fiveSeconds();
      try
       {
          WebElement subElement = driver.findElement(By.id(menuItem));
          String urlLink = subElement.getAttribute("href");
          JavascriptExecutor js = (JavascriptExecutor) driver;
         
            
          System.out.println(urlLink);
         wait_fiveSeconds();
         js.executeScript("arguments[0].setAttribute('target', arguments[1]);", subElement, "_self");
         js.executeScript("arguments[0].click();", subElement);
           wait_fiveSeconds();
          checkUrl(urlName, pageTitle, urlLink);
       }
      
       catch (Exception e)
       {
          System.out.println(e);
          msg = urlName + " test was not successful" +
                System.getProperty("line.separator") + System.getProperty("line.separator") + e;
          new SendMail(to_email,urlName,msg);
          errorsFound = true;
          driver.navigate().to(baseUrl);
       }
       wait_fiveSeconds();
   }

rodale_janet
Active particpant
Active particpant

Posts : 10
Join date : 2014-03-07

Back to top Go down

Re: Automate sending an email in Selenium IDE

Post by Sponsored content


Sponsored content


Back to top Go down

View previous topic View next topic Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum