예제 #1
0
        //[TestMethod]
        public void CheckPriceTagOnCheckoutPage()
        {
            string        expectedPriceTag  = "Online price";
            IndexHomePage indexPage         = new IndexHomePage(Driver, Url);
            string        firstManufacturer = indexPage.TopHeader.GetManufacturerMenuOptionsText().ElementAtOrDefault(1);

            indexPage.TopHeader.SetManufacturerDropdown(firstManufacturer);
            ProductListPage productsListPage = indexPage.TopHeader.ClickOnSubmit();
            var             firstProductItem = productsListPage.GetResultItems().FirstOrDefault();

            firstProductItem.ClickOnAddToCart();
            productsListPage.WaitForAppBusy();
            indexPage = productsListPage.TopHeader.ClickOnLogo();
            CartPage cartPage = indexPage.UtilityMenu.ClickOnCart();

            cartPage.WaitUntilItemsAreDisplayed();
            SignInRegisterPage signInPage   = cartPage.ClickOnProceedToCheckoutButtonAnonymous();
            CheckoutPage       checkoutPage = signInPage.ClickOnCheckoutAsGuest();

            checkoutPage.WaitUntilItemsAreDisplayed();
            var productItems = checkoutPage.GetProductItems();

            foreach (var product in productItems)
            {
                System.Console.WriteLine(product.GetItemDetail(ProductItemDetailsEnum.PriceTag));
                Assert.AreEqual(expectedPriceTag, product.GetItemDetail(ProductItemDetailsEnum.PriceTag));
            }
        }
예제 #2
0
        public void AddToCartLogIn()
        {
            ProductListPage page = new ProductListPage();

            page.AddToCartLogIn(driver);
            driver.Quit();
        }
예제 #3
0
        //[TestMethod]
        public void CheckCartOnlinePriceTag()
        {
            string        expectedTagName    = "Online price";
            IndexHomePage indexHomePage      = new IndexHomePage(Driver, Url);
            var           manufacturers      = indexHomePage.TopHeader.GetManufacturerMenuOptionsText();
            string        secondManufacturer = manufacturers.ElementAt(1);

            indexHomePage.TopHeader.SetManufacturerDropdown(secondManufacturer);
            ProductListPage productListPage = indexHomePage.TopHeader.ClickOnSubmit();
            var             firstItem       = productListPage.GetResultItems().FirstOrDefault();

            firstItem.ClickOnAddToCart();
            //productListPage.IsAppBusy();
            //Go back to index page
            indexHomePage = productListPage.TopHeader.ClickOnLogo();
            CartPage cartPage = indexHomePage.UtilityMenu.ClickOnCart();

            cartPage.WaitUntilItemsAreDisplayed();
            var cartItems = cartPage.GetProductItems();

            foreach (var item in cartItems)
            {
                //check each item for tag value
                Assert.AreEqual(expectedTagName, item.GetItemDetail(ProductItemDetailsEnum.PriceTag));
            }
        }
예제 #4
0
        public static bool GetMenus()
        {
            IList <string> urlsList = new List <string>();

            Thread.Sleep(TimeSpan.FromSeconds(10));
            IList <IWebElement> nav   = Driver.Instance.FindElements(By.ClassName("nav-item "));
            IList <IWebElement> links = nav[0].FindElements(By.TagName("a"));

            foreach (IWebElement link in links)
            {
                if (link.GetAttribute("href") != null)
                {
                    urlsList.Add(link.GetAttribute("href"));
                }
            }


            foreach (string url in urlsList)
            {
                ProductListPage plp = new ProductListPage();
                plp.URL  = url;
                plp.Name = "Name";
                Driver.Instance.Navigate().GoToUrl(url);

                if (Header.IsPLP())
                {
                    DataBase.InsertProductListPage(url);
                    var PDPId  = DataBase.AddPLP(plp);
                    var result = Header.SaveAllProducts(url);
                }
            }

            return(true);
        }
예제 #5
0
        public void GivenUserSelectsAProduct()
        {
            ProductListPage     plp        = new ProductListPage(Driver);
            IList <IWebElement> dressToBuy = Driver.FindElements(plp.dressesList);

            dressToBuy[0].Click();
        }
예제 #6
0
        public static ProductListPageViewModel Create(ProductListPage currentPage)
        {
            var model = new ProductListPageViewModel(currentPage);

            PageViewModelBuilder.SetBaseProperties(model);
            model.Products = FakeProductDatabase.GetProducts();
            return(model);
        }
예제 #7
0
 public void TestInitialize()
 {
     driver = new ChromeDriver();
     driver.Manage().Window.Maximize();
     driver.Navigate().GoToUrl("http://opencart.abstracta.us/");
     homePage        = new HomePage(driver);
     productListPage = homePage.NavigateToTabletsProductList(driver);
     menuItem        = new MenuItemControl(driver);
 }
예제 #8
0
        public void AddToCartNotLogIn()
        {
            ProductListPage page = new ProductListPage();

            page.AddToCartNotLogIn(driver);
            var text = driver.FindElement(By.ClassName("alert-danger")).Text;

            Assert.AreEqual(text, "Musisz być zalogowany");
            driver.Quit();
        }
 public void TestInitialize()
 {
     driver = new ChromeDriver();
     driver.Manage().Window.Maximize();
     driver.Navigate().GoToUrl("http://opencart.abstracta.us/");
     homePage            = new HomePage(driver);
     productListPage     = homePage.NavigateToTabletsProductList(driver);
     productPage         = productListPage.NavigateToProductPage(driver);
     AddProductNewReview = productPage.OpenReviewTab(driver);
 }
예제 #10
0
        public void PageSwapProductPages()
        {
            switch (ProductIndex)
            {
            case 0:
                Frame = new ProductCreatePage();
                break;

            case 1:
                Frame = new ProductListPage();
                break;
            }
        }
 public void TestInitialize()
 {
     options = new ChromeOptions();
     options.AddArgument("--ignore-ssl-errors=yes");
     options.AddArgument("--ignore-certificate-errors");
     driver = new ChromeDriver(options);
     driver.Manage().Window.Maximize();
     driver.Navigate().GoToUrl("http://opencart.abstracta.us/");
     menuItem        = new MenuItemControl(driver);
     homePage        = new HomePage(driver);
     productListPage = homePage.NavigateToTabletsProductList(driver);
     productListPage.AddToCartFirstProduct(shoppingCartBO);
     shoppingCartPage = menuItem.NavigateToShoppingCart(driver);
 }
예제 #12
0
        //[TestMethod]
        public void CheckProductListOnlinePriceTag()
        {
            string        expectedPriceTag = "Online price";
            IndexHomePage indexHomePage    = new IndexHomePage(Driver, Url);
            var           manufacturers    = indexHomePage.TopHeader.GetManufacturerMenuOptionsText();
            string        manufacturer     = manufacturers.ElementAt(1);

            indexHomePage.TopHeader.SetManufacturer(manufacturer);
            ProductListPage productListPage = indexHomePage.TopHeader.ClickOnSubmit();
            var             productItems    = productListPage.GetResultItems();

            var incorrectPriceTag = productItems.FirstOrDefault(p => p.GetItemDetail(ProductItemDetailsEnum.PriceTag) != expectedPriceTag);

            Assert.IsNull(incorrectPriceTag, $"Theres an invalid Price tag on {manufacturer}");
        }
예제 #13
0
        //[TestMethod]
        public void CheckProductDetailOnlinePriceTag()
        {
            string        expectedPriceTag = "Online price";
            IndexHomePage indexPage        = new IndexHomePage(Driver, Url);
            var           manufacturers    = indexPage.TopHeader.GetManufacturerMenuOptionsText();
            //Get the second manufacturer
            string manufacturer = manufacturers.ElementAtOrDefault(1);

            indexPage.TopHeader.SetManufacturer(manufacturer);
            ProductListPage   productListPage   = indexPage.TopHeader.ClickOnSubmit();
            var               productItem       = productListPage.GetResultItems().FirstOrDefault();
            ProductDetailPage productDetailPage = productItem.Click();
            string            actualPriceTag    = productDetailPage.GetProductSection(ProductDetailSections.PriceTag);

            Assert.AreEqual(expectedPriceTag, actualPriceTag);
        }
예제 #14
0
        public SearchViewModel()
        {
            SearchHistoryList = new ObservableCollection <string>();

            //InitSearchPage();

            SearchCommand = new Command <string>(async(str) =>
            {
                if (!Tools.IsNetConnective())
                {
                    CrossToastPopUp.Current.ShowToastError("无网络连接,请检查网络。", ToastLength.Long);
                    return;
                }

                if (string.IsNullOrEmpty(str))
                {
                    CrossToastPopUp.Current.ShowToastWarning("请输入关键词", ToastLength.Short);
                }
                else
                {
                    if (!SearchHistoryList.Contains(str))
                    {
                        SearchedItem searchedItem = new SearchedItem
                        {
                            createTime     = DateTime.UtcNow.ToString(),
                            searchedString = str
                        };
                        await LocalDatabaseHelper <SearchedItem> .InsertOrReplaceAsync(searchedItem);
                    }

                    ProductListPage productListPage = new ProductListPage(str);
                    SearchString = "";
                    await Application.Current.MainPage.Navigation.PushAsync(productListPage);
                }
            }, (str) => { return(true); });

            ClearCommand = new Command(async() =>
            {
                bool action = await Application.Current.MainPage.DisplayAlert("确认", "删除所有搜索历史?", "确认", "取消");
                if (action)
                {
                    await localDatabaseService.DeleteAllSearchedItem();
                    InitSearchPage();
                }
            }, () => { return(true); });
        }
예제 #15
0
        public FindMoreViewModel()
        {
            SubCategoryList = new ObservableCollection <Category>();

            InitCategories();

            SearchCommand = new Command(() =>
            {
                SearchPage searchPage = new SearchPage();
                Application.Current.MainPage.Navigation.PushAsync(searchPage);

                /*
                 * if (!Tools.IsNetConnective())
                 * {
                 *  CrossToastPopUp.Current.ShowToastError("无网络连接,请检查网络。", ToastLength.Long);
                 *  return;
                 * }
                 *
                 * if (string.IsNullOrEmpty(SearchString))
                 * {
                 *  CrossToastPopUp.Current.ShowToastWarning("请输入关键词", ToastLength.Short);
                 * }
                 * else
                 * {
                 *  ProductListPage productListPage = new ProductListPage(SearchString);
                 *  SearchString = "";
                 *
                 *  Application.Current.MainPage.Navigation.PushAsync(productListPage);
                 * }*/
            }, () => { return(true); });

            ItemTappedCommand = new Command <int>((id) =>
            {
                foreach (var item in SubCategoryList)
                {
                    if (item.id == id)
                    {
                        ProductListPage productListPage = new ProductListPage(item);
                        Application.Current.MainPage.Navigation.PushAsync(productListPage);
                    }
                }
            }, (id) => { return(true); });
        }
예제 #16
0
        public void CheckPrice()
        {
            MainPage mainPage = new MainPage(_driver, null);

            ProductListPage productsPage = mainPage
                                           .OpenMenu()
                                           .ChangeLanguageToUkr()
                                           .CloseMenu()
                                           .Search("Lenovo");

            var firstPrice = productsPage.GetFirstProductPrice();

            ProductPage productPage = productsPage.VisitFirstProduct();

            var secondPrice = productPage.GetPrice();

            Assert.That(firstPrice == secondPrice, "Price #1 is not equal to Price #2");
            Console.WriteLine("Price #1 and #2 are identical.");

            var thirdPrice = ((ProductListPage)productPage.Back()).GetFirstProductPrice();

            Assert.That(firstPrice == thirdPrice, "Price #1 is not equal to Price #3");
            Console.WriteLine("Price #1 and #3 are identical.");
        }
예제 #17
0
        public CategoryViewModel()
        {
            ParentCategoryList = new ObservableCollection <Category>();
            SubCategoryList    = new ObservableCollection <Category>();
            categoryList       = new List <Category>();

            InitCategories();

            SearchCommand = new Command(() =>
            {
                SearchPage searchPage = new SearchPage();
                Application.Current.MainPage.Navigation.PushAsync(searchPage);
            }, () => { return(true); });

            ReloadCommand = new Command(() =>
            {
            }, () => { return(true); });

            ParentCategoryTappedCommand = new Command(() =>
            {
                GetSubCategories(SelectedParent.id);
            }, () => { return(true); });

            SubCategoryTappedCommand = new Command <int>((id) =>
            {
                foreach (var item in SubCategoryList)
                {
                    if (item.id == id)
                    {
                        ProductListPage productListPage = new ProductListPage(item);
                        Application.Current.MainPage.Navigation.PushAsync(productListPage);
                        break;
                    }
                }
            }, (id) => { return(true); });
        }
 public ProductListPageSteps()
 {
     _productListPage = new ProductListPage();
 }
예제 #19
0
        public HomeViewModel()
        {
            CarouselList   = new List <HomePanelContent>();
            CatList        = new List <Category>();
            HotProductList = new List <HomePanelContent>();

            MemberVisible = GlobalVariables.IsLogged;

            InitHomePage();

            CarouselTappedCommand = new Command <int>((position) =>
            {
                string url      = CarouselList[position].fullUrl;
                WebPage webPage = new WebPage(url);
                Application.Current.MainPage.Navigation.PushAsync(webPage);
            }, (position) => { return(true); });

            FindMoreCommand = new Command <int>((id) =>
            {
                foreach (var item in CatList)
                {
                    if (item.id == id)
                    {
                        ProductListPage productListPage = new ProductListPage(item);
                        Application.Current.MainPage.Navigation.PushAsync(productListPage);
                    }
                }
            }, (id) => { return(true); });

            SearchCommand = new Command(() =>
            {
                SearchPage searchPage = new SearchPage();
                Application.Current.MainPage.Navigation.PushAsync(searchPage);
            }, () => { return(true); });

            NavigateCommand = new Command <string>((pageName) =>
            {
                Type type = Type.GetType(pageName);
                Page page = (Page)Activator.CreateInstance(type);
                Application.Current.MainPage.Navigation.PushAsync(page);
            }, (pageName) => { return(true); });

            ItemTapCommand = new Command <long>((id) =>
            {
                ProductDetailPage productDetailPage = new ProductDetailPage(id.ToString());
                //NavigationPage navigationPage = new NavigationPage(productDetailPage);
                Application.Current.MainPage.Navigation.PushAsync(productDetailPage);
            }, (id) => { return(true); });

            MoreCatCommand = new Command(() =>
            {
                FindMorePage findMorePage = new FindMorePage();
                Application.Current.MainPage.Navigation.PushAsync(findMorePage);
            }, () => { return(true); });

            GetRebateCommand = new Command(() =>
            {
                try
                {
                    if (!string.IsNullOrWhiteSpace(PasteString))
                    {
                        string paras         = PasteString.Split('#')[2];
                        byte[] bytes         = Convert.FromBase64String(paras);
                        string decodedString = System.Text.Encoding.Default.GetString(bytes);

                        JObject json = JObject.Parse(decodedString);
                        ProductDetailPage productDetailPage = new ProductDetailPage(json["p"].ToString());
                        Application.Current.MainPage.Navigation.PushAsync(productDetailPage);
                    }
                }
                catch (Exception)
                {
                    CrossToastPopUp.Current.ShowToastError("出现错误。", ToastLength.Short);
                    throw;
                }
            }, () => { return(true); });
        }
예제 #20
0
        public HomeViewModel()
        {
            CarouselList   = new List <HomePanelContent>();
            CatList        = new List <Category>();
            HotProductList = new List <HomePanelContent>();

            MemberVisible = GlobalVariables.IsLogged;

            InitHomePage();

            //TimerCallback timerDelegate = new TimerCallback(Tick);
            //timer = new Timer(timerDelegate, null, 0, 5000); //5秒执行一次Tick方法

            CarouselTappedCommand = new Command <int>((position) =>
            {
                string url      = CarouselList[position].fullUrl;
                WebPage webPage = new WebPage(url);
                Application.Current.MainPage.Navigation.PushModalAsync(webPage);
            }, (position) => { return(true); });

            FindMoreCommand = new Command <int>((id) =>
            {
                foreach (var item in CatList)
                {
                    if (item.id == id)
                    {
                        ProductListPage productListPage = new ProductListPage(item);
                        Application.Current.MainPage.Navigation.PushModalAsync(productListPage);
                    }
                }
            }, (id) => { return(true); });

            SearchCommand = new Command(() =>
            {
                if (!Tools.IsNetConnective())
                {
                    CrossToastPopUp.Current.ShowToastError("无网络连接,请检查网络。", ToastLength.Long);
                    return;
                }

                if (string.IsNullOrEmpty(SearchString))
                {
                    CrossToastPopUp.Current.ShowToastWarning("请输入关键词", ToastLength.Short);
                }
                else
                {
                    ProductListPage productListPage = new ProductListPage(SearchString);
                    SearchString = "";
                    Application.Current.MainPage.Navigation.PushModalAsync(productListPage);
                }
            }, () => { return(true); });

            NavigateCommand = new Command <string>((pageName) =>
            {
                Type type = Type.GetType(pageName);
                Page page = (Page)Activator.CreateInstance(type);
                Application.Current.MainPage.Navigation.PushModalAsync(page);
            }, (pageName) => { return(true); });

            ItemTapCommand = new Command <long>((id) =>
            {
                ProductDetailPage productDetailPage = new ProductDetailPage(id.ToString());
                Application.Current.MainPage.Navigation.PushModalAsync(productDetailPage);
            }, (id) => { return(true); });

            MoreCatCommand = new Command(() =>
            {
                FindMorePage findMorePage = new FindMorePage();
                Application.Current.MainPage.Navigation.PushModalAsync(findMorePage);
            }, () => { return(true); });
        }
예제 #21
0
        public void RegisterWebShopHandlers()
        {
            var app = Application.Current;
            app.Use(new HtmlFromJsonProvider());
            app.Use(new PartialToStandaloneHtmlProvider());

            Handle.GET("/webshop/rootpage", () =>
            {
                Session session = Session.Current;

                if (session != null && session.Data != null)
                    return session.Data;

                var standalone = new RootPage();

                if (session == null)
                {
                    session = new Session(SessionOptions.PatchVersioning);
                    standalone.Html = "/Webshop/RootPage.html";
                }

                standalone.Session = session;
                return standalone;
            });

            Handle.GET("/webshop", () =>
            {
                RootPage master = (RootPage)Self.GET("/webshop/rootpage");
                master.CurrentPage = Db.Scope(() => {
                    var page = new ProductListPage
                    {
                        Html = "/Webshop/Partials/ProductsList/ProductListPage.html",
                        Data = new Order
                        {
                            Buyer = new Simplified.Ring1.Somebody
                            {
                                Name = "Buyer name"
                            },
                            Seller = new Simplified.Ring1.Somebody
                            {
                                Name = "Seller name"
                            },
                        }
                    };
                    page.RefreshProducts();
                    return page;
                });

                return master;
            });

            Handle.GET("/webshop/{?}", (long objectNo) => {

                RootPage master = (RootPage)Self.GET("/webshop/rootpage");

                master.CurrentPage = Db.Scope(() => {

                    var page = new ProductListPage
                    {
                        Html = "/Webshop/Partials/ProductsList/ProductListPage.html",
                        Data = Db.SQL<Order>("SELECT i FROM Simplified.Ring6.\"Order\" i WHERE i.ObjectNo = ?", objectNo).First,
                        ObjectNo = objectNo,
                        Products = Db.SQL<Product>("SELECT jk FROM Simplified.Ring3.Product jk")
                    };
                    return page;
                });

                return master;
            });

            Handle.GET("/webshop/basket/{?}", (long objectNo) => {

                RootPage master = (RootPage)Self.GET("/webshop/rootpage");

                master.CurrentPage = Db.Scope(() => {

                    var page = new BasketPage
                    {
                        Html = "/Webshop/Partials/BasketPages/BasketPage.html",
                        ObjectNo = objectNo,
                        Data = Db.SQL<Order>("SELECT i FROM Simplified.Ring6.\"Order\"  i WHERE i.ObjectNo = ?", objectNo).First
                    };

                    return page;

                });

                return master;
            });

            Handle.GET("/checkout/shipping/{?}", (long objectNo) =>
            {
                RootPage master = (RootPage)Self.GET("/webshop/rootpage");

                master.CurrentPage = Db.Scope(() =>
                {
                    var page = new ShippingInformationPage
                    {
                        Html = "/Webshop/Partials/CheckoutPages/ShippingInformationPage.html",
                        ObjectNo = objectNo,
                        Data = Db.SQL<Order>("SELECT i FROM Simplified.Ring6.\"Order\"  i WHERE i.ObjectNo = ?", objectNo).First
                    };

                    return page;
                });

                return master;
            });

            Handle.GET("/checkout/payment/{?}", (long objectNo) =>
            {

                RootPage master = (RootPage)Self.GET("/webshop/rootpage");

                master.CurrentPage = Db.Scope(() =>
                {
                    var page = new PaymentMethodsPage
                    {
                        Html = "/Webshop/Partials/CheckoutPages/PaymentMethodsPage.html",
                        Data = Db.SQL<Order>("SELECT i FROM Simplified.Ring6.\"Order\"  i WHERE i.ObjectNo = ?", objectNo).First,
                        ObjectNo = objectNo
                    };

                    return page;
                });

                return master;
            });

            Handle.GET("/checkout/summary/{?}", (long objectNo) =>
            {
                RootPage master = (RootPage)Self.GET("/webshop/rootpage");

                master.CurrentPage = Db.Scope(() =>
                {
                    var page = new CheckoutSummaryPage();
                    var order = Db.SQL<Order>("SELECT i FROM Simplified.Ring6.\"Order\" i WHERE i.ObjectNo = ?", objectNo).First;
                    page.Data = order;
                    if (order.IsPayed)
                    {
                        page.Result.Message = "Order is processing. Your payment was paid.";
                        page.Result.IsSuccessful = true;
                    }
                    else
                    {
                        page.Result.Message = "Order waiting for your payment.";
                        page.Result.IsSuccessful = false;
                    }

                    return page;
                });

                return master;
            });

            Handle.GET("/webshop/settings", () =>
            {
                RootPage master = (RootPage)Self.GET("/webshop/rootpage");
                master.CurrentPage = Db.Scope(() =>
                {
                    var page = new SettingPage
                    {
                        Html = "/Webshop/Partials/Settings/SettingPage.html"
                    };
                    page.LoadDefaultData();
                    return page;
                });
                return master;
            });
        }
 public static ProductListPageViewModel Create(ProductListPage currentPage) {
     var model= new ProductListPageViewModel(currentPage);
     PageViewModelBuilder.SetBaseProperties(model);
     model.Products = FakeProductDatabase.GetProducts();
     return model;
 }
예제 #23
0
 public void WhenISearchProductPollutionMask(string productName)
 {
     productListPage = homePage.SearchProduct(productName);
 }
예제 #24
0
        public CategoryViewModel()
        {
            ParentCategoryList = new ObservableCollection <Category>();

            SubCategoryList = new ObservableCollection <Category>();

            categoryList = new List <Category>();

            SearchString = "";

            //InitCategories();

            //Application.Current.MainPage.FindByName<StackLayout>("ParentStack").Children[0].Behaviors[0].SetValue(RadioBehavior.IsCheckedProperty, true);
            //GetSubCategories(ParentCategoryList[0].id);

            SearchCommand = new Command(() =>
            {
                if (!Tools.IsNetConnective())
                {
                    CrossToastPopUp.Current.ShowToastError("无网络连接,请检查网络。", ToastLength.Long);
                    return;
                }

                if (string.IsNullOrEmpty(SearchString))
                {
                    CrossToastPopUp.Current.ShowToastWarning("请输入关键词", ToastLength.Short);
                }
                else
                {
                    ProductListPage productListPage = new ProductListPage(SearchString);
                    SearchString = "";

                    Application.Current.MainPage.Navigation.PushModalAsync(productListPage);
                }
            }, () => { return(true); });

            ReloadCommand = new Command(() =>
            {
            }, () => { return(true); });

            ParentCategoryTappedCommand = new Command <int>((parentId) =>
            {
                //foreach (var item in ParentCategoryList)
                //{
                //    item.Checked = item.id == parentId;
                //}
                GetSubCategories(parentId);
            }, (id) => { return(true); });

            SubCategoryTappedCommand = new Command <int>((id) =>
            {
                foreach (var item in SubCategoryList)
                {
                    if (item.id == id)
                    {
                        ProductListPage productListPage = new ProductListPage(item);
                        Application.Current.MainPage.Navigation.PushModalAsync(productListPage);
                    }
                }
            }, (id) => { return(true); });
        }