Sunday, January 12, 2020

[FIX] The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.7.0 Authentication Required.

I got above error when i try to send my test results at the [AssemblyCleanup] step on my automation test suite.
This is how my code looks like.

 public static void SendEmail()
        {

            string fromAddress = "@gmail.com";
            string mailPassword = "";
            SmtpClient SmtpServer = new SmtpClient("smtp.gmail.com");
            SmtpServer.Port = 587;
            SmtpServer.EnableSsl = true;
            SmtpServer.DeliveryMethod = SmtpDeliveryMethod.Network;
            SmtpServer.UseDefaultCredentials = false;
            SmtpServer.Credentials = new System.Net.NetworkCredential(fromAddress, mailPassword);
          

            MailMessage myMail = new System.Net.Mail.MailMessage();
            myMail.From = new MailAddress("xxxx@gmail.com");
            myMail.To.Add("xxxx");
            myMail.To.Add("xxxx");

            myMail.Subject = " Test Results";
         
            String body = "Test Status";
            myMail.IsBodyHtml = true;
            myMail.Body = body;
            myMail.Attachments.Add(new Attachment(@"..\..\..\xx\Reports\xx.html"));


            SmtpServer.Send(myMail);

        }

But still Im getting the above error so the solution was to enable Less secure app access by navigating to below URL
https://myaccount.google.com/u/3/lesssecureapps?pli=1&pageId=none

Then update your Gmail password to a very strong password.

Wednesday, January 8, 2020

WebDriver Wait - IMPLICIT & EXPLICIT

IMPLICIT - suggested though not directly expressed - Not the best practise.

driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(10);

An implicit wait is to tell WebDriver to poll the DOM for a certain amount of time when trying to find an element or elements if they are not immediately available. The default setting is 0. Once set, the implicit wait is set for the life of the WebDriver object instance.


EXPLICIT - stated clearly and in detail - The best practise.

in some cases, if any element is taking too much time to be visible on the software web page then you can use EXPLICIT WAIT condition in your test case.