Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java Play! Framework 1.2.4: Exracting link value from Mockmail with selenium

hi there i am trying to test a scenario where mockmail sends an email with a link, the user will clck on the link and he will be a verified user. heres my mockmail output:

14:52:04,664 INFO  ~ From Mock Mailer
    New email received by
    From: [email protected]
    ReplyTo: [email protected]
    To: "[email protected]" <[email protected]>
    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>

and heres my selenium code:

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

i can extract the subject value from the email but i dont kow how to extract the link from the tag from the mail body.

Thanks for helping...

like image 423
dreampowder Avatar asked Sep 16 '26 04:09

dreampowder


1 Answers

Use this commands

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

Hope it helps :)

like image 77
Venkatesh Avatar answered Sep 19 '26 02:09

Venkatesh



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!