1

I'm using WebDriver and Java to automate some web pages. I have a scenario that I'm not sure the best way to manage. A website provides the option to leave a comment, but if you are not a user it sends you the email with a link to click to activate the user and add the comment. Is there a clean way to automate leaving the site to wait for the email, and when it's found clicking the link.

Ripon Al Wasim
  • 36,924
  • 42
  • 155
  • 176
Green
  • 1,405
  • 4
  • 21
  • 27

2 Answers2

1

Consider using JavaMail API and HTTPURLConnection. This is what I do in a similar testing scenario.

While running the webdriver test, after doing certain action if you expect an email then using JavaMail API poll (for a certain timeout if its not immediate) for the email in the background with certain 'subject' or 'sender' etc. Once the email is found then grab the link from the email content and then simulate a click using HTTPURLConnection

nilesh
  • 14,131
  • 7
  • 65
  • 79
1

You could use GreenMail - it is embeddable test mail server( it is to mail server what h2 and hsql are to databases), wait for sending and receiving of email - parse the email and continue with you test

http://www.icegreen.com/greenmail/

Slavus
  • 1,168
  • 12
  • 20
  • Great tip, I'll be able to use this for some additional testing. Thanks. – Green Oct 05 '11 at 15:14
  • @Slavus: I visited the above link and read. nice article. I have got the line: "GreenMail is the fist and only library that offers a test framework for both receiving and retrieving emails from Java.". I used JavaMail API for sending email. Is JavaMail support for receiving and retrieving email? – Ripon Al Wasim Jan 07 '13 at 10:38