Example #1
0
 public static MailBoxPage LogOut(this MailBoxPage page)
 {
     Console.WriteLine("Log out...");
     page.profile.Click();
     page.logOut.Click();
     return(page);
 }
        public void MainGmailTestBO()
        {
            //XmlConfigurator.Configure();
            //BasicConfigurator.Configure();
            log.Warn("Starting test with Logging");
            log.Info("1. Add logging for step in your solution with log4net libraries. Use different log level, e.g. info, error - DONE");

            LoginPage loginPage = new LoginPage(driver);

            LoginPageWf.LoginToGmail(loginPage, UserName, UserPass);
            Assert.That(driver.Url.Equals("https://mail.google.com/mail/u/0/#inbox"), "Log in failed");
            string to   = UserName + "@gmail.com";
            string subj = "Test subject " + Random;
            string body = "Test mail body text: " + Random;
            Mail   mail = new Mail();

            mail = mail.createMail(subj, to, body);
            MailBoxPage mailPage = new MailBoxPage(driver);

            MailBoxPageWf.CreateAndSaveNewMail(mailPage, mail);
            MailBoxPageWf.CheckDraft(mailPage, mail);
            MailBoxPageWf.SendMailAndCheck(mailPage, mail);
            MailBoxPageWf.LogOut(mailPage);
            Assert.That(driver.Title == "Gmail");
        }
Example #3
0
 //overload to use mail business object
 #region Using Business Object Mail
 public static MailBoxPage CreateAndSaveNewMail(this MailBoxPage page, Mail mail)
 {
     Console.WriteLine("Creating new mail...");
     page.newMailbnt.Click();
     page.toField.SendKeys(mail.MailReceiver);
     page.subjField.SendKeys(mail.MailHeader);
     page.bodyField.Click();
     page.bodyField.SendKeys(mail.MailBody);
     Console.WriteLine("Saving new mail...");
     page.saveAndClose.Click();
     return(page);
 }
Example #4
0
        public static MailBoxPage CheckDraft(this MailBoxPage page, Mail mail)
        {
            Console.WriteLine("Check draft...");
            page.drafts.Click();
            page.requiredMail(mail.MailHeader).Click();
            string to2   = page.receiverToCheck.GetAttribute("email");
            string subj2 = page.subjToCheck.GetAttribute("value");
            string body2 = page.bodyToCheck.Text;

            Assert.AreEqual(mail.MailReceiver, to2, "to are not equal");
            Assert.AreEqual(mail.MailHeader, subj2, "subj are not equal");
            Assert.AreEqual(mail.MailBody, body2, "body are not equal");
            return(page);
        }
Example #5
0
        public static MailBoxPage CreateNewMail(this MailBoxPage page, string to, string subj, string body)
        {
            Console.WriteLine("Creating new mail...");
            page.newMailbnt.Click();
            page.toField.SendKeys(to);
            page.subjField.SendKeys(subj);
            page.bodyField.Click();
            page.bodyField.SendKeys(body);

            //Fill subject using Actions
            //new Actions(page.PageBrowser).SendKeys(page.bodyField,"A"+"F"+Keys.Space+body).Build().Perform();

            Console.WriteLine("Saving new mail...");
            page.saveAndClose.Click();
            return(page);
        }
Example #6
0
        public void MainGmailTest()
        {
            LoginPage loginPage = new LoginPage(driver);

            LoginPageWf.LoginToGmail(loginPage, UserName, UserPass);
            Assert.That(driver.Url.Equals("https://mail.google.com/mail/#inbox"), "Log in failed");

            MailBoxPage mailPage = new MailBoxPage(driver);
            string      to       = UserName + "@gmail.com";
            string      subj     = "Test subject " + Random;
            string      body     = "Test mail body text: " + Random;

            MailBoxPageWf.CreateNewMail(mailPage, to, subj, body);
            MailBoxPageWf.CheckDraft(mailPage, to, subj, body);
            MailBoxPageWf.SendMailAndCheck(mailPage, subj);
            MailBoxPageWf.LogOut(mailPage);
            Assert.That(driver.Title == "Gmail");
        }
        public static LoginPage LoginToGmail(this LoginPage page, string login, string pass)
        {
            //Console.WriteLine("Log in to gmail...");
            if (page.BackArrow.Displayed)
            {
                page.BackArrow.Click();
            }
            page.LoginField.SendKeys(login);
            page.NextButton.Click();
            page.PassField.SendKeys(pass);
            TestBase.HighlightElementAndTakeSS(page.PageBrowser, page.SingInButton);
            log.Fatal("2-3.	Make screenshot with highlighted element and save it with human-friendly format (e.g. date_time.png) - DONE");
            page.SingInButton.Click();

            //new waiting
            MailBoxPage mailBox = new MailBoxPage(page.PageBrowser);

            TestBase.WaitForElement(page.PageBrowser, mailBox.profile);
            return(page);
        }
Example #8
0
        public static MailBoxPage SendMailAndCheck(this MailBoxPage page, Mail mail)
        {
            Console.WriteLine("Sending mail...");
            page.sendMailbtn.Click();

            //Send mail using JS
            //IJavaScriptExecutor js = page.PageBrowser as IJavaScriptExecutor;
            //js.ExecuteScript("arguments[0].click();", page.sendMailbtn);

            //Thread.Sleep(3000);
            //new waiting
            TestBase.WaitForElement(page.PageBrowser, page.sentConfirmation);

            Console.WriteLine("Checking mail...");
            string a = string.Format("//div[@role='main']//span[contains(., '{0}')]", mail.MailHeader);

            page.sent.Click();

            //Thread.Sleep(3000);
            //new waiting
            TestBase.WaitForTab(page.PageBrowser, "#sent");

            var x = page.PageBrowser.FindElements(By.XPath(a)).Count;

            Assert.That(x == 1, "mail was not sent");
            page.drafts.Click();

            //Thread.Sleep(3000);
            //new waiting
            TestBase.WaitForTab(page.PageBrowser, "#drafts");

            var y = page.PageBrowser.FindElements(By.XPath(a)).Count;

            Assert.That(y == 0, "mail is still in draft");
            return(page);
        }