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;
        }
Example #2
0
 public Mail createMail(string MailHeader, string MailReceiver, string MailBody)
 {
     Mail newMail = new Mail();
     newMail.setHeader(MailHeader);
     newMail.setReceiver(MailReceiver);
     newMail.setMailBody(MailBody);
     return newMail;
 }
 //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;
 }
 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;
 }
        public void MainGmailTestBO()
        {
            LoginPage loginPage = new LoginPage(driver);
            LoginPageWf.LoginToGmail(loginPage, UserName, UserPass);
            Assert.That(driver.Url.Equals("https://mail.google.com/mail/#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");

        }
 public void FactoryMethodTestMain()
 {
     IWebDriver driver = factoryDriver.CreateDriver();
     driver.Navigate().GoToUrl(HomePage);
     LoginPage loginPage = new LoginPage(driver);
     LoginPageWf.LoginToGmail(loginPage, UserName, UserPass);
     Assert.That(driver.Url.Equals("https://mail.google.com/mail/#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");
     driver.Quit();
 }