I am trying to automate a scenario wherein I am Signing Up on a WebApp which will take my email address and send a Link to my Email address using which I can create my Password. I want to retrieve that CreatePassword link using Seleniunm-C#. I have automated up to the point where I click on Sign Up enter my details(Name, Email Address) and clicking on SignUp button which will generate a Password Link and send to my Email Address.

  • What problem do you face? You should have web interface for your mail-box. Then use Selenium to get to your mailbox using web and click the link there. – Alexey R. Feb 7 '18 at 9:34
  • That is an option. But I do not want Selenium to go and enter my credentials on the mailbox and then retrieve the email after logging in. Is there any other way? Third party utility to fetch email from particular account? Is this even possible, without actually going to my mailbox? – seleniumTester Feb 7 '18 at 10:36

Easiest options would be:

1. Test email account

Create a test account where the password can be known by the team. Then, simply use this mailbox in your test as no information has to remain hidden. So Selenium can log in and get the link.

2. Test email account as proxy

If you need a 'real' email address for the test, create a test account as per above. Then, have the test account import email from the real account. Of course, this will be default get all mails... so further investigation needed.

3. API call and/or faking the link

If that really is too much of a hassle, you can skip the manual part entirely with some creativity.

  • Are there API calls available that you can access in your test? Maybe you can get the link this way?

  • Does the same user/password combination always generate the same link?

  • Can you insert a record into the database that will work with a link you created yourself?

For example, in my tests, by setting the same password hash in the database guarantees that my test users can all log in with the same password.

  • Thanks for the answer. My developer is dumping all the Emails to a particular MailGroup (for Testers). Say, a user has signed up using test@test.com, we will get an email to our mailbox containing link for test@test.com user. I am not aware of API calls/ or faking the link. – seleniumTester Feb 7 '18 at 12:33
  • @FDM, if you are able to use the same hash for different users, then the security of your database is weak: dustwell.com/how-to-handle-passwords-bcrypt.html. Better safe than sorry. – Florent B. Feb 7 '18 at 14:47
  • I mean Hash and Salt, no idea if that makes a difference. I'm not a security expert. :) – FDM Feb 7 '18 at 15:05
  • Going with taking the Verification Link directly from Database with Read-Only test account access. – seleniumTester Feb 8 '18 at 11:23
  • @AmanShukla good choice; as I was suggesting in 3. it's usually preferred if you can skip manual parts in an automated test. – FDM Feb 8 '18 at 14:45

Yes you can use Gmail API...if you are using gmail id. Here you can Read and send messages, work with labels, and search for specific threads.

  • User's credentials could still be found in the test data then? – FDM Feb 7 '18 at 11:02

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.