0

In one of my test cases, I'm able to get the entire HTML e-mail message sent to a user. The message contains text, button, a link, etc.

My Issue is that I need to extract the href link in order to use it for the next function. I have been checking the protractor API, unfortunately I was not successful in finding the correct method which can be used in this case.

E.g. of HTML message:

<table border="0" cellspacing="0" cellpadding="0" width="100%">
   <tr>
      <td align="center">
         <table border="0" cellspacing="0" cellpadding="0" width="600">
               <tr>
                   <td>
                      <a href="http://domain.io/ui/confirm?d=true&token=eyJ0eXAiOiJKV1QiLCJjdHkiOiJKV1QiLCJhbGciOiJIUz....
                   </td>
               </tr>
         </table>
      </td>
   </tr>
</table>

How can I extract the <a href.. value? I mean how can I get the link?

  • What is your output when you use the getText method? – demouser123 Feb 19 '18 at 14:45
  • @demouser123: The output is the code I have posted in my question. Any way, issue has been solved. see my answer. – k.vincent Feb 19 '18 at 14:47
1

Issue fixed. My bad... was thinking more complicated than it's. It's even not something protractor specific. just native JavaScript

Solution:

var getHref = email['html'].match(/href="([^"]*)/)[1];

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.