private void SelectCategoryHelper(string category, StringComparison stringComparison) { var foundItem = false; var links = CategoriesComponent.GetItems() .Select(e => e.FindElement(By.CssSelector("a"))); foreach (var item in links) { var text = item.TextHelper().InnerText; var matches = String.Equals( category, text, stringComparison); if (matches) { foundItem = true; item.Click(); break; } } if (!foundItem) { throw new NoSuchElementException(); } }
/// <summary> /// Gets the current category. /// </summary> /// <returns></returns> public virtual string GetCurrentCategory() { var selectedCategory = CategoriesComponent.GetItems() .FirstOrDefault(e => e.Classes().Contains("active")); return(selectedCategory?.TextHelper().InnerText); }
/// <summary> /// If overriding don't forget to call base.Load() or make sure to /// assign the WrappedElement. /// </summary> /// <returns></returns> public override ILoadableComponent Load() { base.Load(); CategoriesComponent.Load(); ManufacturerComponent.Load(); LimitedToStoresComponent.Load(); return(this); }
/// <summary> /// Gets the categories. /// </summary> /// <returns></returns> public virtual IEnumerable <string> GetCategories() { var categories = CategoriesComponent .GetItems() .Select(e => e.FindElement(linkSelector) .TextHelper() .InnerText); return(categories); }
/// <summary> /// Sets the categories. /// </summary> /// <param name="categories">The categories.</param> /// <returns></returns> public virtual MappingComponent SetCategories(IEnumerable <string> categories) { var selectedItems = CategoriesComponent.GetSelectedOptions(); var deselectedItems = selectedItems.Except(categories); var itemsToSelect = categories.Except(selectedItems); foreach (var item in deselectedItems) { CategoriesComponent.DeselectItem(item); } foreach (var category in itemsToSelect) { CategoriesComponent.SelectItem(category); } return(this); }
/// <summary> /// Gets the available options for categories. /// </summary> /// <returns></returns> public virtual IEnumerable <string> GetAvailableOptionsForCategories() { return(CategoriesComponent.GetAllOptions()); }
/// <summary> /// Gets the categories. /// </summary> /// <returns></returns> public virtual IEnumerable <string> GetCategories() { return(CategoriesComponent.GetSelectedOptions()); }