简体   繁体   中英

How to verify mask letter in email using java

I will get random email id in my confirmation page.That should be in below format. a****a@gmail.com Can I verify email format in selenium?

<div class="cart-wrapper grid-container">
<div class="grid-40">
<div class="cart-confirmation-copy">
<p class="cart-confirmation-email">A***A@gmail.COM</p>
</div>
</div>

beside using selenium use JavaMail to validate the email format. You just need to getText() from selenium then pass it to the function

Using the official java email package is the easiest:

public static boolean isValidEmailAddress(String email) {
   boolean result = true;
   try {
      InternetAddress emailAddr = new InternetAddress(email);
      emailAddr.validate();
   } catch (AddressException ex) {
      result = false;
   }
   return result;
}

Hope it will help you :)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM