3

您好,我正在尝试测试模拟邮件发送带有链接的电子邮件的场景,用户将点击链接,他将成为经过验证的用户。这是我的模拟邮件输出:

14:52:04,664 INFO  ~ From Mock Mailer
    New email received by
    From: Admin@xxx.com.tr
    ReplyTo: Admin@xxx.com.tr
    To: "xxx@hotmail.com" <xxx@hotmail.com>
    Subject: Verification 
    text/html; charset=UTF-8: <html>
    <body>
        <p>Click here to verify your password: <a href="http://localhost:9000/usercontroller/verifyforgotpassword?uuid=6aaf15da-75ca-44f4-9d3d-c9056d33e142"/></p>
    </body>
</html>

这是我的硒代码:

#{selenium}
open('/usercontroller/forgotpassword')
type('userid','stat-011032')
click('btnLogin')
storeLastReceivedEmailBy('xxx@hotmail.com', 'email')
store('javascript{/Subject:\s+(.*)/.exec(storedVars["email"])[1]}', 'subject')
assertEquals('Verification', '$[subject]')
#{/selenium}

我可以从电子邮件中提取主题值,但我不知道如何从邮件正文的标签中提取链接。

感谢您的帮助...

4

1 回答 1

2

使用此命令

store('javascript{/http:[^\s]+/.exec(storedVars["email"])[0]}', 'confirmationUrl')
open($[confirmationUrl])

希望能帮助到你 :)

于 2012-12-13T15:11:53.243 回答