/// <summary> /// Method for preloading all goods on one page and create a collection of them ready for later usage /// </summary> /// <param name="homepage"></param> /// <param name="goods"></param> public static void PreloadGoods(this RozetkaFilterHome homepage, out ReadOnlyCollection <IWebElement> goods) { while (true) { try { //Give some time for the page to load Thread.Sleep(LoadingTimeout); homepage.MoreGoodsPane.Click(); //Find (implicitly) the loader element and press it } catch (System.Reflection.TargetInvocationException) { break; //If the element isn't found this either means that we've reached the limit or we are too slow. in either case, we stop } catch (NoSuchElementException) { break; //same here } goods = homepage.contGoods.FindElements(By.ClassName(GoodsClassName)); //Select all the objects that contain links to goods if (goods.Count > GoodsTestedCount) { break; } } goods = homepage.contGoods.FindElements(By.ClassName(GoodsClassName)); }
static void Main(string[] args) { //Start chrome and navigate to target page IWebDriver driver = new ChromeDriver(); //IWebDriver driver = new FirefoxDriver(); driver.Navigate().GoToUrl("http://rozetka.com.ua/notebooks/c80004/filter/"); //Create corresponding PO RozetkaFilterHome homepage = new RozetkaFilterHome(driver); //Intialize selected criteria container Dictionary <Enum, List <Enum> > selected_criteria_set; Utilities.SelectRandomCriteriaSet(homepage.FilterEnumToCheckboxDictionary, out selected_criteria_set); foreach (Enum key in selected_criteria_set.Keys) { Console.Write(key.ToString() + ": "); foreach (Enum item in selected_criteria_set[key]) { Console.Write(item.ToString() + ", "); } Console.WriteLine(); } //Preload routine ReadOnlyCollection <IWebElement> goods; homepage.PreloadGoods(out goods); CheckCriteria(driver, goods[0], selected_criteria_set); Thread.Sleep(5000); }
public void TestFilters() { //Create corresponding PO RozetkaFilterHome homepage = new RozetkaFilterHome(driver); //Intialize selected criteria container Dictionary <Enum, List <Enum> > selected_criteria_set; Utilities.SelectRandomCriteriaSet(homepage.FilterEnumToCheckboxDictionary, out selected_criteria_set); //Preload routine ReadOnlyCollection <IWebElement> goods; homepage.PreloadGoods(out goods); foreach (IWebElement item in goods) { CheckCriteria(driver, item, selected_criteria_set); } }
static void Main(string[] args) { //Start chrome and navigate to target page IWebDriver driver = new ChromeDriver(); //IWebDriver driver = new FirefoxDriver(); driver.Navigate().GoToUrl("http://rozetka.com.ua/notebooks/c80004/filter/"); //Create corresponding PO RozetkaFilterHome homepage = new RozetkaFilterHome(driver); //Intialize selected criteria container Dictionary<Enum, List<Enum>> selected_criteria_set; Utilities.SelectRandomCriteriaSet(homepage.FilterEnumToCheckboxDictionary, out selected_criteria_set); foreach (Enum key in selected_criteria_set.Keys) { Console.Write(key.ToString() + ": "); foreach (Enum item in selected_criteria_set[key]) { Console.Write(item.ToString()+", "); } Console.WriteLine(); } //Preload routine ReadOnlyCollection<IWebElement> goods; homepage.PreloadGoods(out goods); CheckCriteria(driver, goods[0], selected_criteria_set); Thread.Sleep(5000); }
public void TestFilters() { //Create corresponding PO RozetkaFilterHome homepage = new RozetkaFilterHome(driver); //Intialize selected criteria container Dictionary<Enum, List<Enum>> selected_criteria_set; Utilities.SelectRandomCriteriaSet(homepage.FilterEnumToCheckboxDictionary, out selected_criteria_set); //Preload routine ReadOnlyCollection<IWebElement> goods; homepage.PreloadGoods(out goods); foreach (IWebElement item in goods) { CheckCriteria(driver, item, selected_criteria_set); } }