public void SendEmail(string recipient, string message)
        {
            try
            {
                MainEmailBoxPage mainPage = new MainEmailBoxPage();

                mainPage.WaitTillElementIsVisible(_composeButtonXPath);
                mainPage.ComposeButton.Click();

                EmailForm emailForm = new EmailForm();

                emailForm.WaitTillElementIsVisible(_sendFormXPath);
                Browser.GetDriver().SwitchTo().ActiveElement();

                emailForm.ToField.SendKeys(recipient);
                emailForm.ToField.SendKeys(Keys.Enter);
                emailForm.MessageArea.SendKeys(message);
                emailForm.MessageArea.SendKeys(Keys.Enter);
                Thread.Sleep(2000);
                emailForm.SendButton.Click();

                Logger.Configure();
                Log.Information($"Email with the text'{message}' was sent to '{recipient}'");
            }
            catch (Exception ex)
            {
                Logger.Configure();
                Log.Error(ex, $"Email was not sent to '{recipient}'");
            }
        }
        public LogInForm SignOut()
        {
            try
            {
                MainEmailBoxPage mainPage = new MainEmailBoxPage();
                mainPage.LinkToAccountPopUp.Click();
                mainPage.WaitTillElementIsVisible(_signOutButtonBy);
                mainPage.SignOutButton.Click();
                IWebDriver driver = Browser.GetDriver();

                if (driver.IsAlertPresent())
                {
                    driver.SwitchTo().Alert();
                    driver.SwitchTo().Alert().Dismiss();
                    driver.SwitchTo().DefaultContent();
                }

                Logger.Configure();
                Log.Information($"User was sign out'");
            }
            catch (Exception ex)
            {
                Logger.Configure();
                Log.Error(ex, "User didn't sign out");
            }

            return(new LogInForm());
        }
Example #3
0
        public MainEmailBoxPage LogInToEmailBox(string email, string password)
        {
            try
            {
                HomePage   homePage = new HomePage();
                IWebDriver driver   = Browser.GetDriver();
                driver.Manage();

                LogInForm logInForm = new LogInForm();

                WaitTillElementIsVisible(_logInForm);

                if (RussianLanguageIsSelected.Displayed)
                {
                    RussianLanguageIsSelected.Click();
                    WaitTillElementIsVisible(_contentBy);
                    EnglishLanguage.Click();
                    WaitTillElementIsVisible(_logInForm);
                }

                if (driver.IsElementDisplayed(_changeUserButton))
                {
                    ChangeUserButton.Click();
                }
                if (driver.IsElementDisplayed(_useAnotherAccountBy))
                {
                    logInForm.UseAnotherAccountButton.Click();
                }

                //Enter credentials
                logInForm.WaitTillElementIsVisible(_loginInputBy);
                logInForm.LogInInput.SendKeys(email);
                logInForm.NextEmailButton.Click();

                logInForm.WaitTillElementIsVisible(_passwordInputBy);
                logInForm.PasswordInput.SendKeys(password);
                logInForm.PasswordInput.HighlightElement(_passwordInputBy);
                logInForm.NextPasswordButton.Click();

                //Wait till main mail box page is loaded
                MainEmailBoxPage mainEmailBoxPage = new MainEmailBoxPage();

                mainEmailBoxPage.WaitTillElementIsVisible(_composeButtonBy);

                Logger.Configure();
                Log.Information($"I login with the following credentials: '{email}' / '{password}'");
            }
            catch (Exception ex)
            {
                Logger.Configure();
                Log.Error(ex, "Log in to the email box was failed");
            }

            return(new MainEmailBoxPage());
        }
        public void DeleteEmail(string sender)
        {
            try
            {
                MainEmailBoxPage mainPage = new MainEmailBoxPage();

                string              emailName       = String.Format(_emailNameXPath, sender);
                IWebElement         emailTitle      = Browser.GetDriver().FindElement(By.XPath(emailName));
                MainNavigationPanel navigationPanel = new MainNavigationPanel();

                navigationPanel.MoreButton.Click();

                Actions Action = new Actions(Browser.GetDriver());
                Action.DragAndDrop(emailTitle, navigationPanel.TrashButton).Build().Perform();

                Logger.Configure();
                Log.Information($"Email from {sender} was deleted'");
            }
            catch (Exception ex)
            {
                Logger.Configure();
                Log.Error(ex, "Email was not deleted");
            }
        }