Example #1
0
        public void EnterInvalidCredentials()
        {
            string         username = "******";
            string         password = "******";
            LoginPageModel page     = new LoginPageModel(this.TestObject);

            page.OpenLoginPage();
            Assert.IsTrue(page.LoginWithInvalidCredentials(username, password));
        }
Example #2
0
        public void FunWithTabsAndiFrames()
        {
            // Open a page with an iFrame
            WebDriver.Navigate().GoToUrl("https://magenicautomation.azurewebsites.net/Automation/iFramePage");

            // Launch a new tab
            string newTab = "window.open('https://magenicautomation.azurewebsites.net');";

            ((IJavaScriptExecutor)WebDriver).ExecuteScript(newTab);

            // Switch to new/last tab
            WebDriver.SwitchTo().Window(WebDriver.WindowHandles.Last());

            // Interact with page
            LoginPageModel page = new LoginPageModel(this.TestObject);

            page.OpenLoginPage();
            page.EnterCredentials("Bad", "StillBad");

            // Switch back to origianl tab and interact with the iFrame content
            WebDriver.SwitchTo().Window(WebDriver.WindowHandles.First());
            WebDriver.SwitchTo().Frame("mageniciFrame");

            WebDriver.FindElement(By.CssSelector("[href='https://magenic.com/contact']")).Click();
            WebDriver.FindElement(By.CssSelector("[placeholder='First Name']")).SendKeys("Ted");
            WebDriver.FindElement(By.CssSelector("[placeholder='Last Name']")).SendKeys("Johnson");

            // Do to top level page and interact withit
            WebDriver.SwitchTo().DefaultContent();
            WebDriver.FindElement(By.CssSelector("#ContactButton A")).Click();

            // Switch to last tab
            WebDriver.SwitchTo().Window(WebDriver.WindowHandles.Last());
            page.LoginWithInvalidCredentials("Worse", "FarWorse");
            Assert.IsTrue(page.ErrorMessage.Displayed, "Error message should be displayed");
        }