Webdriver 在 Gmail 中打开邮件 [英] Webdriver to open a mail in Gmail

查看:13
本文介绍了Webdriver 在 Gmail 中打开邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经开始使用 Webdriver 来自动化我们的测试,这是 100% 手动的.

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

在其中一个用例中,我需要单击发送到用户收件箱的链接.在这种情况下,我遇到了 Gmail 的问题.登录后,我无法弄清楚如何打开特定的电子邮件.

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.

我知道电子邮件主题等,但我无法使用它来访问该元素.Gmail 将其所有数据作为 JSON 接收,然后通过 js 函数构建整个页面.因此,webdriver 无法访问使用接收到的 JSOn 数据构建的任何元素.

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.

非常感谢任何帮助.

谢谢,克里斯.

推荐答案

我建议不要使用 UI 来验证 Gmail.Gmail 的用户界面非常复杂,而且是个陷阱.对我来说,使用 selenium 实现自动化根本不是解决方案.

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.

考虑使用 JavaMail APIHTTPURLConnection.这是我在类似的测试场景中所做的.

Consider using JavaMail API and HTTPURLConnection. This is what I do in a similar testing scenario.

在运行 webdriver 测试时,如果您希望收到一封电子邮件,则在执行某些操作后,然后使用 JavaMail API 在后台使用特定主题"或发件人"等对电子邮件进行轮询(如果不是即时的,则为特定超时).一旦找到电子邮件,然后从电子邮件内容中获取链接,然后使用 HTTPURLConnection

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

这篇关于Webdriver 在 Gmail 中打开邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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