Exemplo n.º 1
0
        public static void ValidateCouponByMaxUses(IWebDriver driver, string MaxUses)
        {
            //Initialize my CouponsPage POM
            CouponsPage CouponsPage = new CouponsPage(driver);

            //Initialize variables
            string CouponMaxUses = WebDriverUtils.GetElementText(CouponsPage.MaxUsesField);
            string values;

            Thread.Sleep(2000);

            if (ValidateIfNoElementsFoundExist(CouponsPage.NoFoundElementsField) == true)
            {
                values = CouponMaxUses;
                try
                {
                    Assert.IsTrue(values == MaxUses);
                }
                catch (Exception e)
                {
                    Console.Write("Max Uses field is not displayed correctly., Message:{0}", e.Message);
                    throw;
                }
            }
        }
Exemplo n.º 2
0
 public async void Initialize(CouponsPage page)
 {
     this.couponsPage = page;
     Coupons          = new ObservableCollection <Coupon>();
     IsBarcodeVisible = false;
     await LoadCoupons();
 }
Exemplo n.º 3
0
        public static void ValidateDeletedCoupon(IWebDriver driver, string deletevalue)
        {
            //Initialize my CouponsPage POM
            CouponsPage CouponsPage = new CouponsPage(driver);

            //Initialize variables
            bool exists = false;

            Thread.Sleep(2000);
            if (ValidateIfNoElementsFoundExist(CouponsPage.NoFoundElementsField) == false)
            {
                exists = false;
            }
            else
            {
                exists = CouponsPage.CouponId.Displayed.Equals(deletevalue);
            }

            try
            {
                Assert.IsFalse(exists);
            }
            catch (Exception e)
            {
                Console.Write("Element was not Deleted successfully", e.Message);
            }
        }
Exemplo n.º 4
0
        public static void ValidateSearchField(IWebDriver driver, string value)
        {   //Initialize my CouponsPage POM
            CouponsPage CouponsPage = new CouponsPage(driver);

            //Initialize variables
            bool   failed           = false;
            string CouponCode       = WebDriverUtils.GetElementText(CouponsPage.CouponCodeField);
            string CouponPercentage = WebDriverUtils.GetElementText(CouponsPage.PercentageField);
            string CouponMaxUses    = WebDriverUtils.GetElementText(CouponsPage.MaxUsesField);

            if (ValidateIfNoElementsFoundExist(CouponsPage.NoFoundElementsField) == true)
            {
                if (CouponCode == value)
                {
                    failed = true;
                }
                else
                {
                    Thread.Sleep(3000);
                    if (CouponPercentage == value)
                    {
                        failed = true;
                    }
                    else
                    {
                        if (CouponMaxUses == value)
                        {
                            failed = true;
                        }
                        else
                        {
                            failed = false;
                        }
                    }
                }
            }
            else
            {
                failed = false;
            }

            try
            {
                Assert.IsTrue(failed);
            }
            catch (Exception e)
            {
                Console.Write("No elements were found for the given value to serch., Message:{0}", e.Message);
                throw;
            }
        }
Exemplo n.º 5
0
 public static void ValidateCouponbyPercentage(CouponsPage CouponsPage, IWebDriver driver, string percentage)
 {
     try
     {
         Logger.Info("Assert if CouponPercentage == percentage");
         Assert.AreEqual(percentage, CouponsPage.CouponPercentageMethod());
     }
     catch (Exception e)
     {
         Logger.Error("They are not Equal");
         Console.Write("Percentage field is not displayed correctly., Message:{0}", e.Message);
         Assert.Fail();
     }
 }
Exemplo n.º 6
0
 public static void ValidateDeletedCoupon(CouponsPage CouponsPage, IWebDriver driver, string deletevalue)
 {
     try
     {
         Logger.Info("Try to Assert if the coupon doesn't exist");
         Assert.IsFalse(CouponsPage.CouponDeletedMethod(deletevalue));
     }
     catch (Exception e)
     {
         Logger.Error("The Coupon still exists");
         Console.Write("Element was not Deleted successfully", e.Message);
         Assert.Fail();
     }
 }
Exemplo n.º 7
0
 public static void ValidateSearchField(CouponsPage CouponsPage, IWebDriver driver, string value)
 {
     Logger.Info("inside ValidateSearchField");
     try
     {
         Logger.Info("Try to Assert if search didn't fail");
         Assert.IsTrue(CouponsPage.SearchFieldMethod(value));
     }
     catch (Exception e)
     {
         Logger.Error("There was no field with that value");
         Console.Write("No elements were found for the given value to search., Message:{0}", e.Message);
         Assert.Fail();
     }
 }
Exemplo n.º 8
0
 public static void ValidateCouponByMaxUses(CouponsPage CouponsPage, IWebDriver driver, string MaxUses)
 {
     Logger.Info("Inside ValidateCouponByMaxUses");
     try
     {
         Logger.Info("Try to Assert if CouponMaxUses == MaxUses");
         Assert.AreEqual(MaxUses, CouponsPage.MaxUsesMethod());
     }
     catch (Exception e)
     {
         Logger.Error("They are not equal");
         Console.Write("Max Uses field is not displayed correctly., Message:{0}", e.Message);
         Assert.Fail();
     }
 }
Exemplo n.º 9
0
        public static void ValidateCouponbyCouponCode(CouponsPage CouponsPage, IWebDriver driver, string CouponCode)
        {
            Logger.Info("Inside ValidateCouponbyCouponCode");

            try
            {
                Logger.Info("Try to Assert if CouponCodeval == CouponCode");
                Assert.AreEqual(CouponCode, CouponsPage.CouponCodeMethod());
            }
            catch (Exception e)
            {
                Logger.Error("They are not the same");
                Console.Write("Coupon Code field is not displayed correctly., Message:{0}", e.Message);
                Assert.Fail();
            }
        }
Exemplo n.º 10
0
        public void TC31_Coupon_SearchedCouponSuccessfully()
        {
            Logger.Info("test Case name TC31_Coupon_SearchedCouponSuccessfully");
            string Value = ConfigurationManager.AppSettings["number"];

            //Execution
            DashBoard   dashboard = new DashBoard(driver);
            CouponsPage coupons   = dashboard.goToCouponsPage();

            Logger.Info("SearchCoupon " + Value);
            coupons.SearchCoupon(Value);

            //Validation
            Logger.Info("ValidateSearchField");
            CouponsPageValidations.ValidateSearchField(coupons, driver, Value);
            Thread.Sleep(1000);
        }
Exemplo n.º 11
0
        public void TC27_Coupons_AddedCouponSuccessfully()
        {
            Logger.Info("Test Case Name TC27_Coupons_AddedCouponSuccessfully");
            string percentage = ConfigurationManager.AppSettings["percentage"];

            //Execution
            DashBoard dashboard = new DashBoard(driver);

            Logger.Info("Go to CouponsPage");
            CouponsPage coupons   = dashboard.goToCouponsPage();
            string      CodeValue = coupons.AddCouponWithGenericCode(percentage);

            coupons.SearchCoupon(CodeValue);

            //Validation
            CouponsPageValidations.ValidateCouponbyPercentage(coupons, driver, percentage);

            Thread.Sleep(1000);
        }
Exemplo n.º 12
0
        public void TC28_Coupons_RemovedCouponSuccessfully()
        {
            Logger.Info("Test Case Name TC28_Coupons_RemovedCouponSuccessfully");
            string valuetodelete = ConfigurationManager.AppSettings["percentage"];

            //Execution
            DashBoard   dashboard = new DashBoard(driver);
            CouponsPage coupons   = dashboard.goToCouponsPage();

            Logger.Info("SearchCoupon " + valuetodelete);
            coupons.SearchCoupon(valuetodelete);
            CouponsPageValidations.ValidateSearchField(coupons, driver, valuetodelete);
            Logger.Info("Delecte Coupon " + valuetodelete);
            coupons.DeleteCoupon(valuetodelete);

            //Validation
            CouponsPageValidations.ValidateDeletedCoupon(coupons, driver, valuetodelete);

            Thread.Sleep(1000);
        }
Exemplo n.º 13
0
        public CouponsPage GetItemsPage(int PageCurrent = 0)
        {
            CouponsPage ModelPage = new CouponsPage();

            try
            {
                var items = from p in entities.CounponTbl
                            orderby p.ID descending
                            select p;

                ModelPage.Total   = items.Count();
                ModelPage.Page    = PageCurrent;
                ModelPage.Coupons = items.Skip((PageCurrent - 1) * PageSize).Take(PageSize).ToList();
                return(ModelPage);
            }
            catch (Exception ex)
            {
                Console.Write(ex);
                throw;
            }
        }
Exemplo n.º 14
0
        public void TC30_Coupons_EditedCouponSuccessfully()
        {
            Logger.Info("test Case name TC_30_Coupons_EditedCouponSuccessfully");
            string MaxUses = ConfigurationManager.AppSettings["MaxUses"];
            string Id      = ConfigurationManager.AppSettings["id"];

            //Execution
            DashBoard   dashboard = new DashBoard(driver);
            CouponsPage coupons   = dashboard.goToCouponsPage();

            Logger.Info("SearchCoupon " + Id);
            coupons.SearchCoupon(Id);
            CouponsPageValidations.ValidateSearchField(coupons, driver, Id);
            Logger.Info("EditCouponOnMaxUseValue " + MaxUses);
            coupons.EditCouponOnMaxUseValue(MaxUses);
            Logger.Info("SearchCoupon " + Id);
            coupons.SearchCoupon(Id);

            //Validation
            CouponsPageValidations.ValidateCouponByMaxUses(coupons, driver, MaxUses);
            Thread.Sleep(1000);
        }
Exemplo n.º 15
0
        public void TC32_Coupon_PrintedCouponSuccessfully()
        {
            Logger.Info("Test Case Name TC32_Coupon_PrintedCouponSuccessfully");
            string ParentWindow;
            string printpage = ConfigurationManager.AppSettings["printpage"];
            string mainpage  = ConfigurationManager.AppSettings["mainpage"];

            //Execution
            DashBoard   dashboard = new DashBoard(driver);
            CouponsPage coupons   = dashboard.goToCouponsPage();

            Logger.Info("OpenPrintWindow");
            ParentWindow = coupons.OpenPrintWindow();

            //Validation
            Logger.Info("ValidateifURLisCorrect " + printpage);
            CouponsPageValidations.ValidateIfURLIsCorrect(driver, printpage);
            Logger.Info("ClosePrintWindow");
            coupons.ClosePrintWindow(ParentWindow);
            CouponsPageValidations.ValidateIfURLIsCorrect(driver, mainpage);
            Thread.Sleep(1000);
        }
Exemplo n.º 16
0
        public static void ValidateCouponbyCouponCode(IWebDriver driver, string CouponCode)
        {
            //Initialize my CouponsPage POM
            CouponsPage CouponsPage = new CouponsPage(driver);

            //Initialize variables
            string CouponCodeval = WebDriverUtils.GetElementText(CouponsPage.CouponCodeField);

            Thread.Sleep(2000);

            if (ValidateIfNoElementsFoundExist(CouponsPage.NoFoundElementsField) == true)
            {
                try
                {
                    Assert.IsTrue(CouponCodeval == CouponCode);
                }
                catch (Exception e)
                {
                    Console.Write("Coupon Code field is not displayed correctly., Message:{0}", e.Message);
                    throw;
                }
            }
        }
Exemplo n.º 17
0
 public ActionResult Coupons()
 {
     try
     {
         int nPage = Convert.ToInt32(Request.QueryString["p"]);
         if (nPage < 1)
         {
             nPage = 1;
         }
         CreateRepos();
         CouponsPage Model = CouponRepo.GetItemsPage(nPage);
         return(View(Model));
     }
     catch (Exception ex)
     {
         Console.Write(ex);
         return(Content("Xảy ra lỗi hệ thống ! Vui lòng thử lại."));
     }
     finally
     {
         DisposeRepos();
     }
 }