Question

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.

Was it helpful?

Solution

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

OTHER TIPS

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/

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top