public void SearchScenarios_Basic() { Header header = new Header(driver, wait); Assert.IsTrue(header.DivSearch.Displayed); header.Search("sofa", 0); CatalogSearchPage catalogSearchPage = new CatalogSearchPage(driver, wait); Assert.IsNotEmpty(catalogSearchPage.LabelCrumbs.Text); // Verification: Search crumbs Assert.IsNotEmpty(catalogSearchPage.LabelResult.Text); // Verification: Search results var items = catalogSearchPage.Items; Assert.Greater(items.Count, 0); // Verification: Search results Assert.IsTrue(items[0].ImgProduct.Displayed); Assert.IsNotEmpty(items[0].LabelPrice.Text); Assert.IsNotEmpty(items[0].ProductName); Assert.IsNotEmpty(items[0].ProductLink); items[0].ImgProduct.Click(); ProductDetailPage productDetailPage = new ProductDetailPage(driver, wait); Assert.IsTrue(productDetailPage.DivProductDetail.Displayed); }
/*public static bool HasPrice() * { * Thread.Sleep(TimeSpan.FromSeconds(2)); * try * { * * * * ProductDetail product = new ProductDetail(); * * product.SKU = Driver.Instance.FindElement(By.ClassName("model-number")).Text; * product.Description = Driver.Instance.FindElement(By.ClassName("the-product-title")).Text; * product.BrandCode = "WHR"; * product.Feature = ""; * product.FeatureDescription = ""; * product.FeatureType = ""; * product.Price = ""; * * * DataBase.ExecuteProcedure(product); * return true; * } * catch (NoSuchElementException e) * { * var SKU = Driver.Instance.FindElement(By.ClassName("model-number")).Text; * DataBase.InsertNotFoundItem(SKU,"WHR"); * return false; * } * } */ public static void getDocuments(string item) { try { IWebElement listOfDocuments = Driver.Instance.FindElement(By.Id("documents")); IWebElement doc = listOfDocuments.FindElement(By.TagName("A")); var a_text = doc.Text; var a_href = doc.GetAttribute("href"); DataBase.AddManual(item, a_text, a_href, "1"); ProductDetailPage pdp = new ProductDetailPage(); pdp.Date = DataBase.GetDateFormatDB(); pdp.ProductoId = item; pdp.URL = Driver.Instance.Url; var PDPId = DataBase.AddPDP(pdp); ProductDetail2 pd = new ProductDetail2(); pd.DetailTypeId = DataBase.GetDetailTypeId("Manual"); pd.Date = DataBase.GetDateFormatDB(); pd.Value = a_href; pd.ProductDetailPageId = PDPId; DataBase.AddProductDetail(pd); } catch (NoSuchElementException e) { DataBase.AddManual(item, "no doc", "no doc", "0"); } }
public ActionResult Detail(int pId = 0) { try { ProductDetailPage mProductDetailPage = new ProductDetailPage(); Product mProduct; ProductType mProductType = new ProductType(); Market mMarket = new Market();; //List<Product> MarketList; List <Product> RelatedList; //List<Product> DiscountList; List <ProductType> mProductTypeList; mProduct = ProductRepos.LayTheoId(pId); if (mProduct != null) { mProductDetailPage.Product = mProduct; mMarket = MarketRepos.LayTheoId((int)mProduct.MarketId); if (mMarket == null) { mMarket = new Market(); } mProductDetailPage.Market = mMarket; //lay chi tiet ve loai san pham mProductType = ProductRepos.LayLoaiSanPhamTheoId((int)mProduct.Type); if (mProductType == null) { mProductType = new ProductType(); } mProductDetailPage.ProductType = mProductType; //lay danh sach san pham cua sieu thi //MarketList = productRepos.getByPageSizeMarketId(1, 6, mMarket.ID); //mProductDetailPage.MarketList = MarketList; RelatedList = ProductRepos.LayDanhSachSanPhamLienQuan((int)mProduct.Type, 12, true); mProductDetailPage.RelatedList = RelatedList; //DiscountList = productRepos.LaySanPhamKhuyenMai(1, 6); //mProductDetailPage.DiscountList = DiscountList; // mProductTypeList = ProductRepos.getProductTypeParent(); mProductDetailPage.ProductTypeList = mProductTypeList; ProductSlideShow ProductImages = new ProductSlideShow(); mProductDetailPage.Images = ProductRepos.LayProductImageTheoIDProduct(mProduct.ID); } mProductDetailPage.ProductLastest = ProductRepos.getProductsRandom(6); //lay chi tiet san pham return(View("Detail", mProductDetailPage)); //if (!Request.Browser.IsMobileDevice) // return View("Detail", mProductDetailPage); //else // return View("MobileDetail", mProductDetailPage); } catch (Exception ex) { return(Content(ex.ToString())); } }
public void DisplayProduct() { if (selectedProduct != null) { var viewModel = new ProductDetailViewModel { SelectedProduct = selectedProduct, Products = products, Position = products.IndexOf(selectedProduct) }; var detailsPage = new ProductDetailPage { BindingContext = viewModel }; App.Current.MainPage.Navigation.PushAsync(detailsPage, true); } }
//[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); }
public void ItemDetailScenarios_Basic() { Header header = new Header(driver, wait); header.Search("sofa"); CatalogSearchPage catalogSearchPage = new CatalogSearchPage(driver, wait); catalogSearchPage.Items[0].ImgProduct.Click(); ProductDetailPage productDetailPage = new ProductDetailPage(driver, wait); Assert.IsTrue(productDetailPage.DivProductImage.Displayed); Assert.IsTrue(productDetailPage.DivProductDetail.Displayed); Assert.IsNotEmpty(productDetailPage.LabelPrice.Text); Assert.IsNotEmpty(productDetailPage.LabelCrumbs.Text); }
public CollectionViewModel() { ProductList = new ObservableCollection <ProductListItem>(); Init(); TappedCommand = new Command <long>((productId) => { ProductDetailPage productDetailPage = new ProductDetailPage(productId.ToString()); Application.Current.MainPage.Navigation.PushAsync(productDetailPage); }, (productId) => { return(true); }); RefreshCommand = new Command(() => { Init(); }, () => { return(true); }); }
public OrderingViewModel(List <CartItemInfo> _productList) { UserName = default; Tel = default; IsDefault = false; InitAddress(); PaymentTypeList = new List <string> { "立即在线支付", "延期一个月", "延期两个月" }; SelectedTypeIndex = 0; ProductList = _productList; ItemNum = 0; foreach (var item in ProductList) { TotalSelectedPrice += item.memberPrice * item.productNum; ItemNum += item.productNum; } OrderCommand = new Command(() => { OrderAsync(); }, () => { return(true); }); AddressManageCommand = new Command(() => { AddressManagePage addressManagePage = new AddressManagePage(); Application.Current.MainPage.Navigation.PushModalAsync(addressManagePage); }, () => { return(true); }); OneTappedCommand = new Command <long>((id) => { ProductDetailPage productDetailPage = new ProductDetailPage(id.ToString()); Application.Current.MainPage.Navigation.PushModalAsync(productDetailPage); }, (id) => { return(true); }); BackCommand = new Command(() => { Application.Current.MainPage.Navigation.PopModalAsync(); }, () => { return(true); }); }
public void GivenIClickAddToCartButtonFromProductDetailPage() { ProductDetailPage mypage = new ProductDetailPage(); mypage.ClickAddWishList(); }
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); }); }
public ActionResult Detail(int pId = 0) { V308CMSEntities mEntities = new V308CMSEntities(); ProductRepository productRepository = new ProductRepository(mEntities); MarketRepository marketRepository = new MarketRepository(mEntities); ProductDetailPage mProductDetailPage = new ProductDetailPage(); Product mProduct; ProductType mProductType = new ProductType(); Market mMarket = new Market();; List <Product> MarketList; List <Product> RelatedList; List <Product> DiscountList; List <ProductType> mProductTypeList; try { mProduct = productRepository.LayTheoId(pId); if (mProduct != null) { mProductDetailPage.Product = mProduct; mMarket = marketRepository.LayTheoId((int)mProduct.MarketId); if (mMarket == null) { mMarket = new Market(); } mProductDetailPage.Market = mMarket; //lay chi tiet ve loai san pham mProductType = productRepository.LayLoaiSanPhamTheoId((int)mProduct.Type); if (mProductType == null) { mProductType = new ProductType(); } mProductDetailPage.ProductType = mProductType; //lay danh sach san pham cua sieu thi MarketList = productRepository.getByPageSizeMarketId(1, 6, mMarket.ID); mProductDetailPage.MarketList = MarketList; RelatedList = productRepository.LayDanhSachSanPhamLienQuan((int)mProduct.Type, 6); mProductDetailPage.RelatedList = RelatedList; DiscountList = productRepository.LaySanPhamKhuyenMai(1, 6); mProductDetailPage.DiscountList = DiscountList; // mProductTypeList = productRepository.getProductTypeParent(); mProductDetailPage.ProductTypeList = mProductTypeList; } //lay chi tiet san pham if (!Request.Browser.IsMobileDevice) { return(View(mProductDetailPage)); } else { return(View("~/Views/Home/MobileDetail.cshtml", mProductDetailPage)); } } catch (Exception ex) { return(Content(ex.InnerException.ToString())); } finally { mEntities.Dispose(); productRepository.Dispose(); } }
public MainViewModel() { LoadedWindowCommand = new RelayCommand <Window>((p) => { return(true); }, (p) => { Isloaded = true; if (p == null) { return; } p.Hide(); LoginWindow loginWindow = new LoginWindow(); loginWindow.ShowDialog(); if (loginWindow.DataContext == null) { return; } var loginVM = loginWindow.DataContext as LoginViewModel; if (loginVM.IsLogin) { p.Show(); } else { p.Close(); } } ); LogoutCommand = new RelayCommand <object>((p) => { return(true); }, (p) => { System.Windows.Application.Current.Shutdown(); }); ProductCommand = new RelayCommand <object>((p) => { return(true); }, (p) => { ProductDetailPage wd = new ProductDetailPage(); wd.ShowDialog(); }); SettingsCommand = new RelayCommand <object>((p) => { return(true); }, (p) => { SettingsWindow wd = new SettingsWindow(); wd.ShowDialog(); }); EmployeeCommand = new RelayCommand <object>((p) => { return(true); }, (p) => { NhanVienWindow wd = new NhanVienWindow(); wd.ShowDialog(); }); KhuyenMaiCommand = new RelayCommand <object>((p) => { return(true); }, (p) => { KhuyenMaiWindow wd = new KhuyenMaiWindow(); wd.ShowDialog(); }); StoreCommand = new RelayCommand <object>((p) => { return(true); }, (p) => { StoreWindow wd = new StoreWindow(); wd.ShowDialog(); }); KhachHangCommand = new RelayCommand <object>((p) => { return(true); }, (p) => { KhachHangWindow wd = new KhachHangWindow(); wd.ShowDialog(); }); ProducerCommand = new RelayCommand <object>((p) => { return(true); }, (p) => { NSXWindow wd = new NSXWindow(); wd.ShowDialog(); }); OrderCommand = new RelayCommand <object>((p) => { return(true); }, (p) => { BillWindow wd = new BillWindow(); wd.ShowDialog(); }); }
public OrderDetailViewModel(long orderId) { Order = new OrderDetail(); DeleteBtnVisible = false; InitOrderDetailPage(orderId); CancelCommand = new Command(async() => { bool action = await Application.Current.MainPage.DisplayAlert("取消订单", "您想要取消订单吗?取消后,我们将为您退回货款并拦截快递。", "是的", "算了"); if (action) { CancelOrder(); InitOrderDetailPage(orderId); } }, () => { return(true); }); HomeCommand = new Command(() => { //Application.Current.MainPage.Navigation.PopToRootAsync(); }, () => { return(true); }); BackCommand = new Command(() => { Application.Current.MainPage.Navigation.PopModalAsync(); }, () => { return(true); }); PayCommand = new Command(() => { PlaceAnOrder(); InitOrderDetailPage(orderId); }, () => { return(true); }); DeleteOrderCommand = new Command(() => { DeleteOrderAsync(); }, () => { return(true); }); DeleteCommand = new Command(() => { DeleteBtnVisible = !DeleteBtnVisible; }, () => { return(true); }); OneTappedCommand = new Command <long>((id) => { ProductDetailPage productDetailPage = new ProductDetailPage(id.ToString()); Application.Current.MainPage.Navigation.PushModalAsync(productDetailPage); }, (id) => { return(true); }); MessagingCenter.Subscribe <object, string>(this, "PaySuccess", (sender, resultStatus) => { switch (resultStatus) { case "9000": CrossToastPopUp.Current.ShowToastSuccess("订单支付成功!", ToastLength.Long); break; case "8000": CrossToastPopUp.Current.ShowToastWarning("正在处理中!", ToastLength.Long); break; case "4000": CrossToastPopUp.Current.ShowToastError("订单支付失败!", ToastLength.Long); break; case "6001": CrossToastPopUp.Current.ShowToastWarning("用户中途取消!", ToastLength.Long); break; case "6002": CrossToastPopUp.Current.ShowToastError("网络连接出错!", ToastLength.Long); break; default: break; } InitOrderDetailPage(orderId); }); }
public CartViewModel() { ItemList = new List <CartItemInfo>(); TotalSelectedPrice = "0"; ItemNumber = "0"; CheckedNumber = 0; //IsAllChecked = false; //AllCheckedButton_Color = Color.LightGray; InitCart(); OrderCommand = new Command(() => { List <CartItemInfo> productList = new List <CartItemInfo>(); foreach (var item in ItemList) { if (item.Checked) { productList.Add(item); } } if (productList.Count == 0) { CrossToastPopUp.Current.ShowToastError("没有选中商品", ToastLength.Long); } else { OrderingPage orderingPage = new OrderingPage(productList); Application.Current.MainPage.Navigation.PushModalAsync(orderingPage); } }, () => { return(true); }); TwoTappedCommand = new Command <long>((id) => { TwoTapped_TappedAsync(id); }, (id) => { return(true); }); OneTappedCommand = new Command <long>((id) => { ProductDetailPage productDetailPage = new ProductDetailPage(id.ToString()); Application.Current.MainPage.Navigation.PushModalAsync(productDetailPage); }, (id) => { return(true); }); CheckedChangedCommand = new Command <long>((id) => { /* * foreach (var item in ItemList) * { * if (item.productId == id) * { * item.Checked = !item.Checked; * } * }*/ OnCount(); }, (id) => { return(true); }); RefreshCommand = new Command(() => { InitCart(); }, () => { return(true); }); }
public static void getInfoFromPDP(string item) { ProductDetailPage pdp = new ProductDetailPage(); pdp.Date = DataBase.GetDateFormatDB(); pdp.ProductoId = item; pdp.URL = Driver.Instance.Url; var PDPId = DataBase.AddPDP(pdp); var Date = DataBase.GetDateFormatDB(); ProductDetail2 pd = new ProductDetail2(); pd.DetailTypeId = DataBase.GetDetailTypeId("Title"); pd.Date = Date; pd.ProductDetailPageId = PDPId; pd.Value = Driver.Instance.FindElement(By.ClassName("the-product-title")).Text; DataBase.AddProductDetail(pd); try { IWebElement mainFeatureElement = Driver.Instance.FindElement(By.Id("features")); IList <IWebElement> mainFeatures = mainFeatureElement.FindElements(By.ClassName("show-more-container")); if (mainFeatures.Count == 0) { } else { var iy = 0; foreach (IWebElement mainFeature in mainFeatures) { IWebElement mainFeatureTitle = mainFeature.FindElement(By.TagName("h4")); IWebElement mainFeatureDescription = mainFeature.FindElement(By.ClassName("additional-content")); pd.DetailTypeId = DataBase.GetDetailTypeId("MainFeatureDescription"); pd.Value = mainFeatureDescription.Text; DataBase.AddProductDetail(pd); pd.DetailTypeId = DataBase.GetDetailTypeId("MainFeatureTitle"); pd.Value = mainFeatureTitle.Text; DataBase.AddProductDetail(pd); iy++; } } } catch (NoSuchElementException e) { } try { IWebElement additionalFeatureElement = Driver.Instance.FindElement(By.Id("additionalFeature")); IList <IWebElement> additionalFeatures = additionalFeatureElement.FindElements(By.ClassName("additional-feature")); if (additionalFeatures.Count == 0) { } else { var iy = 0; foreach (IWebElement additionalFeature in additionalFeatures) { IWebElement additionalFeatureTitle = additionalFeature.FindElement(By.TagName("h5")); IWebElement additionalFeatureDescription = additionalFeature.FindElement(By.TagName("p")); pd.DetailTypeId = DataBase.GetDetailTypeId("AdditionalFeatureDescription"); pd.Value = additionalFeatureDescription.Text; DataBase.AddProductDetail(pd); pd.DetailTypeId = DataBase.GetDetailTypeId("AdditionalFeatureTitle"); pd.Value = additionalFeatureTitle.Text; DataBase.AddProductDetail(pd); iy++; } } } catch (NoSuchElementException e) { } try { IList <IWebElement> thumbs = Driver.Instance.FindElements(By.ClassName("s7thumbcell")); foreach (IWebElement imageElement in thumbs) { string a = imageElement.Text; a = a + ""; } } catch (NoSuchElementException e) { } }
public void WhenIClickTheAddProductButton() { ProductDetailPage.AddProduct(); }
public void ShoppingCartScenarios_WithItems() { Header header = new Header(driver, wait); // step 1: search keyword1, and add the item into cart header.Search("sofa"); CatalogSearchPage catalogSearchPage = new CatalogSearchPage(driver, wait); catalogSearchPage.Items[0].ImgProduct.Click(); ProductDetailPage productDetailPage = new ProductDetailPage(driver, wait); Assert.IsTrue(productDetailPage.DivProductDetail.Displayed); Assert.IsTrue(productDetailPage.DivProductImage.Displayed); Assert.IsTrue(productDetailPage.DivProductDetail.Displayed); productDetailPage.AddToCart(2); ModelAddedCart modelAddedCart = new ModelAddedCart(driver, wait); // TODO: Wait for the model dialog - need to be updated instead of hardcoding here System.Threading.Thread.Sleep(5000); Assert.IsTrue(modelAddedCart.DivContent.Displayed); modelAddedCart.ButtonViewCart.Click(); // step 2: verify shopping cart CheckoutCartViewPage checkoutCartViewPage = new CheckoutCartViewPage(driver, wait); Assert.IsTrue(checkoutCartViewPage.DivItemList.Displayed); Assert.IsTrue(checkoutCartViewPage.ButtonCheckout.Displayed); Assert.IsTrue(checkoutCartViewPage.ButtonContinueShopping.Displayed); Assert.AreEqual(1, checkoutCartViewPage.Items.Count); // step 3: add another item into shopping cart driver.Url = "https://www.costco.com/trunature-Resveratrol-Plus%2c-140-Vegetarian-Capsules.product.100118534.html"; if (!productDetailPage.WaitPageAjaxLoadingCompletion) { Assert.Fail("Redirect failed"); } Assert.IsTrue(productDetailPage.DivProductDetail.Displayed); productDetailPage.AddToCart(); // TODO: Wait for the model dialog - need to be updated instead of hardcoding here System.Threading.Thread.Sleep(5000); if (!modelAddedCart.WaitPageAjaxLoadingCompletion) { Assert.Fail("The ModelAddedCart is not loaded during expected time"); } modelAddedCart.ButtonViewCart.Click(); // step 4: verify shopping cart if (!checkoutCartViewPage.WaitPageAjaxLoadingCompletion) { Assert.Fail("The CheckoutCartViewPage is not loaded during expected time"); } Assert.IsTrue(checkoutCartViewPage.ButtonCheckout.Displayed); Assert.IsTrue(checkoutCartViewPage.ButtonContinueShopping.Displayed); Assert.AreEqual(2, checkoutCartViewPage.Items.Count); }
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); }); }