为了使用Selenium阅读上的Gmail电子邮件 [英] Using selenium in order to read emails on gmail

查看:309
本文介绍了为了使用Selenium阅读上的Gmail电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用硒RC和我试图点击Gmail的特定电子邮件,以获得进入电子邮件页面。具体地说:在Gmail收件箱中,单击电子邮件与特定主题

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.

我无法找到正确的XPath(没有在电子邮件中部分标签的链接)。想法?

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

推荐答案

这个XPath应该做的伎俩:

This XPath should do the trick:

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

... 提供的的你已经先改为canvas_frame框架。否则,它不可能它会在所有的工作。如果你不使用萤火虫来检查HTML,你真的应该这样,我发现这些值。此外,Gmail的结构相当有规律的变化,使Y6类可以改变的任何一天。

... 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

重要:你必须使用clickAt造成的Gmail实现你点击。它不会只用简单的点击命令工作。

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

顺便说一句,我们这样做,为我们自己内部的Gmail的监测,因为它是如此的不稳定,在过去数个月。我们使用我公司的硒基免费监测服务,它可以让你运行Selenium脚本来检查的性能和功能你的网站。

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.

这篇关于为了使用Selenium阅读上的Gmail电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆