public void MainMethod() { Navigator navigator = new Navigator(); // Instanciate objects in the navigator navigator.Create(); // navigate to page navigator.NavigateToPage(); // login to page - return the selenium driver into the var. var driver = navigator.LoginToPage(); // Select Make IVehicleSelector vehicleSelector = new VehicleSelector(driver); vehicleSelector.SelectMake(); // Select Model vehicleSelector.SelectModel(); // Condition Picker var conditionPicker = new ConditionPicker(driver); // Click condition list conditionPicker.ClickConditions(); // Check for the number of pages of the vehicles. var pageCounter = new PageCounter(driver); var pageNum = pageCounter.pageNumChecker(); // check number of pages and return the number of pages // Click next page navigator.pageNum = pageNum; // Set the property for the number of pages first for (int i = 1; i <= pageNum.searchResultsPageCount; i++) { // Call the datascraper and send through an argument for the class to search for. var dataScraper = new DataScraper(driver); dataScraper.GetHtml(tableHTMLtagToScrape); // Click the next page navigator.ClickNextPage(i); } }
private void MainNavigationToLoop(Navigator navigator, string vehicleMake, string vehicleModel, bool?filterCondition, IWebDriver driver, int vehicleID, double?vehicleCondition) { // Set current global search vehicle. AppSettings.setCurrentVehicle(vehicleID); // Begin foreach for all vehicles // Select Make IVehicleSelector vehicleSelector = new VehicleSelector(driver); vehicleSelector.SelectMake(vehicleMake); // Select Model returnCode = vehicleSelector.SelectModel(vehicleModel); if (returnCode == 1) { goto ENDTHISLOOP; } // Check if condition is to be filtered. var searchChecker = new SearchChecker(); if (searchChecker.ConditionFiltered(filterCondition)) { // Condition Picker var conditionPicker = new ConditionPicker(driver, vehicleCondition); // Click condition list conditionPicker.ClickConditions(); } // Click Search button navigator.SearchButtonClicker(driver); // Check for the number of pages of the vehicles. var pageCounter = new PageCounter(driver); var pageNum = pageCounter.pageNumChecker(); // check number of pages and return the number of pages // Click next page navigator.pageNum = pageNum; // Set the property for the number of pages first if (pageNum.searchResultsPageCount > 1) { for (int i = 2; i <= pageNum.searchResultsPageCount; i++) { Console.WriteLine("page number is greater than one so looping..."); // Call the datascraper and send through an argument for the class to search for. // var dataScraper = new DataScraper(driver, vehicleID, searchSessionID); // check for error code then exit // returnCode = dataScraper.GetHtml(tableHTMLtagToScrape); //if (returnCode == 1) { // goto ENDTHISLOOP; //} IRowScraper rowScraper = new RowScraper(driver, vehicleID, searchSessionID); // check for error code then exit returnCode = rowScraper.GetSingleRowHtml(tableSingleRowHtmlTagToScrape); if (returnCode == 999999) { goto ENDTHISLOOP; } // NOW GRAB SINGLE ROWS OF DATA // Click the next page navigator.ClickNextPage(i); } } else { Console.WriteLine("Page number returned is one..."); var dataScraper = new DataScraper(driver, vehicleID, searchSessionID); returnCode = dataScraper.GetHtml(tableHTMLtagToScrape); if (returnCode == 1) { goto ENDTHISLOOP; } } ENDTHISLOOP :; }