public static void CreateSeason(IWebDriver driver, int Year, int Month, int Day, string groupId) { var date = new DateTime(Year, Month, Day); var url = @"https://www.resortpro.net/new/admin/edit_company_season.html?id=0&lodging_type_id=3"; driver.GoTo(url); var _wait = new WebDriverWait(driver, new TimeSpan(0, 0, Config.I.RegularWaitSeconds * 2)); // ждем пока загрузится //_wait.Until(ExpectedConditions.ElementExists(By.CssSelector(".transaction-table"))); //_wait.Until(ExpectedConditions.ElementExists(By.CssSelector("[name=close_button]"))); // Wait for existing of close button _wait.CssSelector("[name=close_button]"); // Group var group_id = driver.FindSelectElementById("group_id"); //20250 - 366 debug //20096 - 365 days group_id.SelectByValue(groupId); driver.JustWait(1); // Name var nameElement = driver.FindElementById("name"); var SeasonName = date.ToString("MM-dd"); nameElement.SendKeys(SeasonName); var dailyCheckboxElement = driver.FindElementByCssSelector("input[type=\"checkbox\"][value=\"1\"]"); dailyCheckboxElement.Click(); //Use Daily Pricing <input type="checkbox" value="1" name="use_pricing_model[]"></td></tr> // Description var descriptionTabA = driver.FindElementByCssSelector("a[href=\"#tab2\"]"); descriptionTabA.Click(); var descriptionElement = driver.FindElementByCssSelector("textarea[name=\"description\"]"); descriptionElement.SendKeys(date.ToString("MMMM dd")); CreatePeriod(driver, Year, Month, Day); // Periods /* for (var Year = 2016; Year < 2026; Year++) * { * CreatePeriod(driver, Year, Month, Day); * } * //*/ }
/// <summary> /// Create seasons for the season group passed. /// </summary> /// <param name="driver">Web driver.</param> /// <param name="seasonGroupId">Season group id.</param> /// <param name="seasonStartDate">Season start date.</param> /// <param name="seasonEndDate">Season end date.</param> public static string CreateSeason(IWebDriver driver, string seasonGroupId, DateTime seasonStartDate, DateTime seasonEndDate, int minNightsStay = 0) { string editSeasonURL = Config.I.StreamLineCreateSeasonURL; string seasonId = string.Empty; try { driver.GoTo(editSeasonURL); var wait = new WebDriverWait(driver, new TimeSpan(0, 0, Config.I.RegularWaitSeconds * 2)); wait.CssSelector("[name=close_button]"); // Group drop down. IWebElement groupDrpDwnLstBox = driver.FindElement(By.Id("group_id")); // This code should be reviewed and changed when the next version of Javascript releases. ((IJavaScriptExecutor)driver).ExecuteScript("var select = arguments[0]; for(var i = 0; i < select.options.length; i++){ if(select.options[i].value == arguments[1]){ select.options[i].selected = true; } }", groupDrpDwnLstBox, seasonGroupId); // Setting the name of the season. var nameElement = driver.FindElementById("name"); nameElement.Clear(); string seasonName = GetSeasonName(seasonStartDate, seasonEndDate); nameElement.SendKeys(seasonName); // Setting the minimum nights stay IWebElement minNightsDrpDwnLstBox = driver.FindElement(By.Id("narrow_defined_days")); ((IJavaScriptExecutor)driver).ExecuteScript("var select = arguments[0]; for(var i = 0; i < select.options.length; i++){ if(select.options[i].value == arguments[1]){ select.options[i].selected = true; } }", minNightsDrpDwnLstBox, minNightsStay); // Use daily pricing checkbox. var dailyCheckboxElement = driver.FindElementByCssSelector("input[type=\"checkbox\"][value=\"1\"]"); dailyCheckboxElement.Click(); // As of now no description needs to be set. // Set the period for the seasons. CreatePeriod(driver, seasonStartDate, seasonEndDate, seasonName); // Check whether season has been created successfully CheckWhetherSeasonCreated(driver); driver.JustWait(10); // Get the season id. seasonId = GetId("id", driver); } catch (Exception) { seasonId = string.Empty; } return(seasonId); }