Пример #1
0
        public void buyTicketFailingTest()
        {
            string url = "http://*****:*****@yahoo.com", "User1*");
            wait.Until(wt => wt.FindElement(By.LinkText("*****@*****.**")));

            url = "http://localhost:49683/Films/Index";
            driver.Navigate().GoToUrl(url);
            int points = filmsPage.getPoints();

            filmsPage.clickOnBuyTicketForTheSecondMovie();
            addClientToMoviePage = new AddClientToMoviePage(driver);
            addClientToMoviePage.buyTickets("2019-02-25", 0);

            driver.FindElement(By.LinkText("MY TICKETS")).Click();
            ReadOnlyCollection <IWebElement> tickets = driver.FindElements(By.ClassName("ticket"));
            int flag = 0;

            foreach (IWebElement ticket in tickets)
            {
                if (ticket.Text.Contains("2019-02-25\r\n") && ticket.Text.Contains("Number of tickets: 0"))
                {
                    flag = 1; break;
                }
            }

            Assert.AreEqual(flag, 0);
        }
Пример #2
0
        public void buyTickets()
        {
            string url = "http://*****:*****@yahoo.com", "User1*");
            wait.Until(wt => wt.FindElement(By.LinkText("*****@*****.**")));

            url = "http://localhost:49683/Films/Index";
            driver.Navigate().GoToUrl(url);
            int points = filmsPage.getPoints();

            filmsPage.clickOnBuyTicketForTheSecondMovie();
            addClientToMoviePage = new AddClientToMoviePage(driver);
            addClientToMoviePage.buyTickets("25-09-2019", 2);
            int newPoints = points + 20;

            if (newPoints >= 50 && newPoints < 100)
            {
                Assert.AreEqual(driver.Url, "http://localhost:49683/Films/Gift1");
                driver.FindElement(By.LinkText("Accept the prize")).Click();
                newPoints -= 50;
            }
            else if (newPoints == 100)
            {
                Assert.AreEqual(driver.Url, "http://localhost:49683/Films/Gift2");
                driver.FindElement(By.LinkText("Accept the prize")).Click();
                newPoints -= 100;
            }
            else if (newPoints > 100)
            {
                Assert.AreEqual(driver.Url, "http://localhost:49683/Films/Gift3");
                newPoints -= 101;
            }
            url = "http://localhost:49683/Films/Index";
            driver.Navigate().GoToUrl(url);
            int currentPoints = filmsPage.getPoints();

            Assert.AreEqual(newPoints, currentPoints);
        }