Beispiel #1
0
        public void PlaceOrderTest()
        {
            // register user
            int randomInt = RandomGenerator.Next(10000);

            HomePage.SignIn();
            LoginPage.GoToRegisterPage("username" + randomInt + "@gmail.com");
            WebDriverWait wait = new WebDriverWait(Driver, TimeSpan.FromSeconds(10));

            wait.Until(d => d.Url.Equals("http://automationpractice.com/index.php?controller=authentication&back=my-account#account-creation"));
            RegisterPage.CreateNewUser("Adam", "Nowak", "12345", "1", "January", "2000", "somestreet", "somecity", "Texas", "11111", "United States", "123-456-789");
            wait.Until(d => d.Url.Equals("http://automationpractice.com/index.php?controller=my-account"));
            IWebElement isUser = Driver.FindElement(By.ClassName("account"));

            Assert.AreEqual("Adam Nowak", isUser.Text);

            // place order
            OrderPage.ClickOnTileTShirts();
            Driver.SwitchTo().Window(Driver.WindowHandles.Last());
            OrderPage.CheckoutProcess();

            // assert if order is placed
            IWebElement ordercomplete = Driver.FindElement(By.ClassName("cheque-indent"));

            Assert.AreEqual("Your order on My Store is complete.", ordercomplete.Text);
            Console.WriteLine("Expected: Your order on My Store is complete. \nActual: {0}", ordercomplete.Text);
            HomePage.SignOut();
        }
        public void AddProductToCartTest()
        {
            // register user
            int randomInt = RandomGenerator.Next(10000);

            HomePage.SignIn();
            LoginPage.GoToRegisterPage("username" + randomInt + "@gmail.com");
            WebDriverWait wait = new WebDriverWait(Driver, TimeSpan.FromSeconds(10));

            wait.Until(d => d.Url.Equals("http://automationpractice.com/index.php?controller=authentication&back=my-account#account-creation"));
            RegisterPage.CreateNewUser("Adam", "Nowak", "12345", "1", "January", "2000", "somestreet", "somecity", "Texas", "11111", "United States", "123-456-789");
            wait.Until(d => d.Url.Equals("http://automationpractice.com/index.php?controller=my-account"));
            IWebElement isUser = Driver.FindElement(By.ClassName("account"));

            Assert.AreEqual("Adam Nowak", isUser.Text);

            // add item to cart
            OrderPage.ClickOnTileTShirts();
            Driver.SwitchTo().Window(Driver.WindowHandles.Last());
            IWebElement cross = Driver.FindElement(By.ClassName("cross"));

            wait.Until(SeleniumExtras.WaitHelpers.ExpectedConditions.ElementToBeClickable(By.ClassName("cross")));

            // assert if order is in the cart
            IWebElement isincart = Driver.FindElement(By.XPath("//*[@id='layer_cart']/div[1]/div[2]/h2/span[2]"));

            Assert.AreEqual("There is 1 item in your cart.", isincart.Text);
            Console.WriteLine("Expected: There is 1 item in your cart. \nActual: {0}", isincart.Text);
            cross.Click();
            HomePage.SignOut();
        }
        public void CreateNewAcountTest()
        {
            // register user
            int randomInt = RandomGenerator.Next(10000);

            HomePage.SignIn();
            LoginPage.GoToRegisterPage("username" + randomInt + "@gmail.com");
            WebDriverWait wait = new WebDriverWait(Driver, TimeSpan.FromSeconds(10));

            wait.Until(d => d.Url.Equals("http://automationpractice.com/index.php?controller=authentication&back=my-account#account-creation"));
            RegisterPage.CreateNewUser("Adam", "Nowak", "12345", "1", "January", "2000", "somestreet", "somecity", "Texas", "11111", "United States", "123-456-789");
            wait.Until(d => d.Url.Equals("http://automationpractice.com/index.php?controller=my-account"));

            // asserst if user is registered
            IWebElement isUser = Driver.FindElement(By.ClassName("account"));

            Assert.AreEqual("Adam Nowak", isUser.Text);
            HomePage.SignOut();
        }