0

During a test automation journey i am running, i need to verify an email address which must be different each time. Instead of using multiple different email address's, we have set up an office 365 account that allows +(number) ie test+1@test.com. Although i know how to create an increment by 1 method i am unsure of how to incorporate that into the email address within a method to give me a different email each time. Apologies if this is already in stack overflow but i couldn't find it. Thanks

M.Dug
  • 3
  • 2
  • 1
    if you know how to do increment one, you know how to do this. it's just that, added with a simple String concatenation – Stultuske Jan 03 '19 at 11:37
  • you can have a look at the following answer. https://stackoverflow.com/questions/45841500/generate-random-emails – joemokenela Jan 03 '19 at 11:44
  • @joemokenela according to the question, that is not what he's looking for – Stultuske Jan 03 '19 at 11:55
  • All, thanks for comments @Stultuske, its the creation of the string im having problems with and incorporating the incremented number into the email. – M.Dug Jan 03 '19 at 13:27
  • @joemokenela im not after a random email as i need it related to the account im using. thanks – M.Dug Jan 03 '19 at 13:28

1 Answers1

1

You can use a dedicated gmail account and before using it you can append +timestamp in it. example: let's say you have a account on gmail ABC@gmail.com Now, every time you use this email for verification append ABC+timestamp@gmail.com this email is new for you application but you will always receive verification code on ABC@gmail. you can read ABC@gmail every time for the latest mail for verification. I have used this methods and it works fine with gmail.

Try to test it manually make and gmail account with any name say Mdug@gmail.com Now send email to Mdug+1@gmail.com using different account. you will receive mail at Mdug@gmail.com because in gmail Mdug+anything@gmail.com == Mdug@gmail.com.

Every time you have to read latest mail in Mdug@gmail.com because every verification code will go there

Instead of using random number you can append (Epoch)timestamp after + in email id because it will always be unique

  • Thanks for your comment. the timestamp is a much better idea then increment by 1 each time. Iv managed to create the string and it now add the time and date within the email address each time its created, this also allows me to know if its the correct email i'm looking at as there can occasionally. Problem solved, thanks all – M.Dug Jan 03 '19 at 13:49
  • integration with third party email sounds awfully slow and fragile,.,.. I'd avoid his – Corey Goldberg Jan 03 '19 at 18:03
  • @CoreyGoldberg yea i agree, i didn't go with something like gmail but i have used my companies email. this issue is now solved for me. thanks all – M.Dug Jan 04 '19 at 09:37