Using selenium in order to read emails on gmail

不羁的心 提交于 2019-12-06 08:31:23

问题


I'm using selenium-rc and I'm trying to click on a specific email on gmail in order to get into the email page. More specifically: on the gmail inbox, click on a email with a specific subject.

I can't find the correct xpath (none of the tags in the email part are links). Ideas?


回答1:


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 login
waitForElementPresent canvas_frame
selectFrame canvas_frame
waitForElementPresent //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.




回答2:


change gmail to basic html mode.




回答3:


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




回答4:


I used this command

clickAt | //table/tbody/tr/td[5]/div[@class='yW'] |

Click at the FROM field of first/recent/top most mail to go to mail detail page. // note: tr for first mail, tr[2] for second and so on.



来源:https://stackoverflow.com/questions/1737957/using-selenium-in-order-to-read-emails-on-gmail

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!