Using selenium in order to read emails on gmail Using selenium in order to read emails on gmail selenium selenium

Using selenium in order to read emails on gmail


This XPath should do the trick:

//div[@class = 'y6']/span[contains(., 'subject_here')]

... provided that you've first changed to the canvas_frame frame. Otherwise, it's unlikely it'll work at all. If you're not using Firebug to inspect the HTML, you really should as that's how I found out these values. Also, the Gmail structure changes fairly regularly, so that y6 class could change any day.

I haven't tested this, but this might work for you:

open http://gmail.com// do the login stuff, click on loginwaitForElementPresent canvas_frameselectFrame canvas_framewaitForElementPresent //div[@class = 'y6']/span[contains(., 'subject_here')]clickAt //div[@class = 'y6']/span[contains(., 'subject_here')] 0,0// do stuff you care about

Important: you have to use clickAt to cause Gmail to realize you're clicking. It doesn't work with just the simple "click" command.

By the way, we do this for our own internal monitoring of Gmail because it's been so unstable over the last few months. We're using my companies Selenium-based free monitoring service, which lets you run Selenium scripts to check performance and functionality of your site.


Is your app a Ruby on Rails one by chance? If so, email spec is a great way to test emails without haveing to mess around with Gmail: http://github.com/bmabey/email-spec