This is a migrated thread and some comments may be shown as answers.

Test Successfull Password Reset Process with Test Studio UI

1 Answer 142 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Greg
Top achievements
Rank 1
Greg asked on 02 Mar 2016, 10:36 PM

Hi,

I am a new test studio user and I am working on some initial test scripts.

One of the first sets of scripts is testing a login including:

  1. Successfull Login
  2. Invalid Password
  3. Change Password (passwords don't match)
  4. Change Password (reset password through email link).

I am wondering is it possible to automate #4 above using the Test Studio UI?

Our password reset process sends an email to the user with a one time use URL.

I suppose the scenario would be to identify a dedicated user account for the email to go to, then login to web mail access with a known email UID/PSW. Select the email. click on the link, and then follow it back through. to access our password reset prompt which is waiting for the new password to be specified.

 

Question is: The link is dynamically generated. How would I account for that?

Or should I be asking for a developer to modify the password reset to have a method that allows for a known Password reset token for this user that is static?

1 Answer, 1 is accepted

Sort by
0
Sailaja
Top achievements
Rank 1
answered on 03 Mar 2016, 03:43 AM

Hi Greg,

Yes you can automate the above four scenarios you have mentioned using TTS.

For dynamically generated email link, You can solve this by adding coded/script step in test. You can follow the sequence below.

1. Add Mail Package to the project (we use MailSystem.NET package to read emails)

2. Add a coded step and write the code to read the email's from given mail box and get the corresponding url.

#####################Sample code for reading email ##################

<Apart from existing using statements add mentioned below using statements>
using ActiveUp.Net.Mail;
using System.Text.RegularExpressions;

class UserManagement_Utilities
    {
public String readMails(String username, String password, String emailId)
        {
            String retval = "false";
            Imap4Client client = new Imap4Client();
            // connect to server
            client.ConnectSsl("imap.gmail.com", 993);
            // authenticate
            client.LoginFast(username, password);
            // select folder
            Mailbox inbox = client.SelectMailbox("inbox");
            int[] ids = inbox.Search("UNSEEN");
            Manager.Current.Log.WriteLine(ids.Length.ToString());
            for (int i = 0; i < ids.Length; i++)
            {
                Message mailmessage = inbox.Fetch.MessageObject(ids[i]);
                //Address adr = msg_first.ConfirmRead;
                if ((mailmessage.Subject).Contains("invited you to join Progress"))
                {
                    Manager.Current.Log.WriteLine("From address is " + mailmessage.From);
                    Manager.Current.Log.WriteLine("Subject is " + mailmessage.Subject);
                    Manager.Current.Log.WriteLine("msg_first is " + mailmessage.ReceivedDate.ToLocalTime());
                    var inputString = mailmessage.BodyHtml.Text;
                    if ((inputString.Contains(emailId)) == false)
                    {
                        Manager.Current.Log.WriteLine("This is not the mail you are looking for");
                        continue;
                    }
                    else
                    {//var matches = Regex.Matches(inputString, @"<a\s+href=""(?<mailto>.*?""></a>");
                        var matches = Regex.Matches(inputString, @"<a\shref=""(?<url>.*?)"">(?<text>.*?)</a>");

                        foreach (Match m in matches)
                        {
                            Manager.Current.Log.WriteLine(m.Groups["url"].Value);
                            if ((m.Groups["text"].Value).Equals("here"))
                            {
                                Manager.Current.Log.WriteLine("URL: " + m.Groups["url"].Value + "  Text: " + m.Groups["text"].Value);
                                retval = m.Groups["url"].Value;
                                client.Command("copy " + ids[i].ToString() + " [Gmail]/Trash");

                            }
                        }
                    }
                }
            }
            Manager.Current.Log.WriteLine("^^^^^^^^^^^^^^ URL VALUE FROM UTILITIES CLASS ^^^^^^^^^^^^^" + retval);
            return retval;
        }
}

Hope this information helps you

Regards,
Sailaja

Tags
General Discussions
Asked by
Greg
Top achievements
Rank 1
Answers by
Sailaja
Top achievements
Rank 1
Share this question
or