Search code examples
seleniumgmailautomated-testswebdriver

Webdriver to open a mail in Gmail


I have started using Webdriver to automate our testing which is 100% manual.

In one of the use cases I need to click on a link sent to the user's inbox. I am facing problems with Gmail in this case. After logging in I am not able to figure out how to open a particular email.

I know the email subject etc but I am unable use it to access the element. Gmail receives all its data as JSON and then build the entire page through js functions. So the webdriver is not able to access any of the elements built using the JSOn data received.

Any help is greatly appreciated.

Thanks, Chris.


Solution

  • I would suggest NOT to use UI to verify Gmail. Gmail's UI is extremely complicated and it's a trap. To me, automating with selenium is not a solution at all.

    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