public ViewBrandIpRegulationForm Submit(BrandIpRegulationData data) { var licenseesList = _driver.FindElementWait(By.XPath("//select[contains(@data-bind, 'options: Model.licensees')]")); var licenseeField = new SelectElement(licenseesList); licenseeField.SelectByText(data.Licensee); _driver.Manage().Window.Maximize(); var brandsList = _driver.FindElementWait(By.XPath("//select[contains(@data-bind, 'options: Model.brands')]")); var brandField = new SelectElement(brandsList); brandField.SelectByText(data.Brand); if (!string.IsNullOrEmpty(data.IpAddress)) { var ipAddress = _driver.FindElementWait(By.XPath("//input[contains(@data-bind, 'value: Model.ipAddress')]")); ipAddress.SendKeys(data.IpAddress); } var description = _driver.FindElementWait(By.XPath("//textarea[contains(@data-bind, 'value: Model.description')]")); description.SendKeys(data.Description); if (data.BlockingType != null) { var blockingTypeList = _driver.FindElementWait(By.XPath("//select[contains(@data-bind, 'options: Model.blockingTypes')]")); var blockingTypeField = new SelectElement(blockingTypeList); blockingTypeField.SelectByText(data.BlockingType); } if (data.RedirectUrl != null) { var redirection = _driver.FindElementWait(By.XPath("//input[contains(@data-bind, 'value: Model.redirectionUrl')]")); redirection.Clear(); redirection.SendKeys(data.RedirectUrl); } _saveButton.Click(); var submittedForm = new ViewBrandIpRegulationForm(_driver); submittedForm.Initialize(); return(submittedForm); }
public ViewBrandIpRegulationForm Submit(BrandIpRegulationData data) { var licenseesList = _driver.FindElementWait(By.XPath("//select[contains(@data-bind, 'options: Model.licensees')]")); var licenseeField = new SelectElement(licenseesList); licenseeField.SelectByText(data.Licensee); //Thread.Sleep(5000); //_driver.ScrollPage(795, 293); _driver.Manage().Window.Maximize(); _driver.FindElementScroll(By.XPath("//div[contains(@data-bind, 'items: Model.assignedBrands')]")); var brandsWidget = new MultiSelectWidget(_driver, By.XPath("//div[contains(@data-bind, 'items: Model.assignedBrands')]")); brandsWidget.SelectFromMultiSelect(data.Brand); //_driver.ScrollPage(795, 215); _driver.FindElementScroll(By.XPath("//input[contains(@data-bind, 'value: Model.ipAddress')]")); if (!string.IsNullOrEmpty(data.IpAddress)) { var ipAddress = _driver.FindElementWait(By.XPath("//input[contains(@data-bind, 'value: Model.ipAddress')]")); ipAddress.SendKeys(data.IpAddress); } _driver.FindElementScroll(By.XPath("//input[contains(@data-bind, 'checked: advancedSettings')]")); if (data.AdvancedSettings) { var advancedSettings = _driver.FindElementWait(By.XPath("//input[contains(@data-bind, 'checked: advancedSettings')]")); advancedSettings.Click(); var multipleIpAddresses = _driver.FindElementWait(By.XPath("//textarea[contains(@data-bind, 'value: Model.ipAddressBatch')]")); multipleIpAddresses.SendKeys(data.MultipleIpAddress); } //_driver.ScrollPage(0, 300); _driver.FindElementScroll(By.XPath("//textarea[contains(@data-bind, 'value: Model.description')]")); var description = _driver.FindElementWait(By.XPath("//textarea[contains(@data-bind, 'value: Model.description')]")); description.SendKeys(data.Description); //var restrictionOption = string.Format("//span[text()='{0}']", data.Restriction); //var restriction = _driver.FindElementWait(By.XPath(restrictionOption)); //restriction.Click(); if (data.BlockingType != null) { var blockingTypeList = _driver.FindElementWait(By.XPath("//select[contains(@data-bind, 'options: Model.blockingTypes')]")); var blockingTypeField = new SelectElement(blockingTypeList); blockingTypeField.SelectByText(data.BlockingType); } if (data.RedirectUrl != null) { var redirection = _driver.FindElementWait(By.XPath("//input[contains(@data-bind, 'value: Model.redirectionUrl')]")); redirection.Clear(); redirection.SendKeys(data.RedirectUrl); } //_driver.ScrollPage(0, 1000); _driver.FindElementScroll(By.XPath("//button[contains(@data-bind, 'click: save')]")); _saveButton.Click(); var submittedForm = new ViewBrandIpRegulationForm(_driver); submittedForm.Initialize(); return(submittedForm); }