public void TC15_UserFilterWithDepartStation()
        {
            Console.WriteLine("TC15 - User can filter \"Manager ticket\" table with Depart Station");
            //1. Navigate to QA Railway Website
            HomePage homePage = new HomePage();

            homePage.Open();

            //2. Login with a valid account
            LoginPage loginPage = homePage.GoToLoginPage();

            homePage = loginPage.Login(user.Email, user.Password);

            //3. Book more than 6 tickets with different Depart Stations
            string[] departStations = { "Sài Gòn", "Phan Thiết", "Nha Trang", "Đà Nẵng", "Quảng Ngãi", "Huế" };
            for (int i = 0; i < 6; i++)
            {
                //Book a ticket
                BookTicketPage bookTicketPage = homePage.GoToBookTicketPage();

                DateTime dateTime = DateTime.Now.AddDays(5);

                Ticket ticket = new Ticket();

                ticket.DepartDate    = dateTime.ToString("M/d/yyyy");
                ticket.DepartStation = departStations[i];
                ticket.SeatType      = "Soft bed with air conditioner";
                ticket.Amount        = "1";

                BookTicketSuccessPage bookTicketSuccessPage = bookTicketPage.BookTicket(ticket);
            }

            //4. Click on "My ticket" tab
            //5. Select one of booked Depart Station in "Depart Station" dropdown list
            //6. Click "Apply filter" button
            //VP. "Manage ticket" table shows correct ticket(s)
            TicketFilter ticketFilter = new TicketFilter();

            ticketFilter.DepartStation = "Nha Trang";
            MyTicketPage myTicketPage = homePage.GoToMyTicketPage().ApplyFilter(ticketFilter);

            Assert.IsTrue(myTicketPage.CheckTicketsExistWithFilter(ticketFilter));

            //Clean-up: Cancel all tickets
            myTicketPage.GoToMyTicketPage().CancelAllTickets();
        }
Exemple #2
0
        public void TC10_UserBookOneTicket()
        {
            Console.WriteLine("TC10 - User can book 1 ticket at a time");
            HomePage homePage = new HomePage();

            homePage.Open();
            LoginPage loginPage = homePage.GoToLoginPage();

            homePage = loginPage.Login(Constant.ValidUsername, Constant.ValidPassword);
            MyTicketPage myTicketPage = homePage.GoToMyTicketPage();

            IWebElement[,] test = TableUtils.getTableData(myTicketPage.GetTableHeader(), myTicketPage.GetTableContent());

            //1. Navigate to QA Railway Website
            //2. Login with a valid account
            //3. Click on "Book ticket" tab
            //4. Select a "Depart date" from the list
            //5. Select "Sài Gòn" for "Depart from" and "Nha Trang" for "Arrive at".
            //6. Select "Soft bed with air conditioner" for "Seat type"
            //7. Select "1" for "Ticket amount"
            //8. Click on "Book ticket" button
            //VP. Message "Ticket booked successfully!" displays.Ticket information display correctly (Depart Date, Depart Station, Arrive Station, Seat Type, Amount)
        }
        public void TC14_UserCancelsTicket()
        {
            Console.WriteLine("TC14 - User can cancel a ticket");
            //1. Navigate to QA Railway Website
            HomePage homePage = new HomePage();

            homePage.Open();

            //2. Login with a valid account
            LoginPage loginPage = homePage.GoToLoginPage();

            homePage = loginPage.Login(user.Email, user.Password);

            //3. Book a ticket
            BookTicketPage bookTicketPage = homePage.GoToBookTicketPage();

            DateTime dateTime = DateTime.Now.AddDays(5);

            Ticket ticket = new Ticket();

            ticket.DepartDate    = dateTime.ToString("M/d/yyyy");
            ticket.DepartStation = "Sài Gòn";
            ticket.ArriveStation = "Nha Trang";
            ticket.SeatType      = "Soft bed with air conditioner";
            ticket.Amount        = "1";

            BookTicketSuccessPage bookTicketSuccessPage = bookTicketPage.BookTicket(ticket);

            //4. Click on "My ticket" tab
            //5. Click on "Cancel" button of ticket which user want to cancel.
            //6. Click on "OK" button on Confirmation message "Are you sure?"
            //VP. The canceled ticket is disappeared.
            MyTicketPage myTicketPage = bookTicketSuccessPage.GoToMyTicketPage().CancelTicket(ticket);

            Assert.IsFalse(myTicketPage.CheckTicketExists(ticket));
        }