Please post your Web Driver questions in official Web Driver forum

Tuesday, August 2, 2011

Verify email confirmation using Selenium

Email confirmation seems to be integral part of any registration process.
I came across an application which lets you provide your email address. You can follow the sign up link in you mail and then complete the registration process.
Lets consider we provide GMail address for it. Now if were to use only Selenium then we would have to follow following steps -

Launch GMail using Selenium; Some how search for new mail in the list of available mails; Some how click on it; Parse the mail message; Get the registration link; Follow up with registration process

What do you think of an approach in which you can

Access GMail using plain java APIs (This in turn uses pop3 or imap); Reach the desired message; Get the registration link; Follow up with registration process

This approach looks far cleaner as we don't have to have UI interaction with GMail.
Java API which I am talking about here is Java Mail. You could find more details on this here -
And here goes the magic code -


And now you can launch registrationURL using Selenium and continue with testing :-)


Fork me on GitHub