Search code examples
javawebdriverjakarta-mailactivationemail-verification

WebDriver Automation on verifying an email


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.


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