public ActionResult Save(LocatorModel model) { string message = ""; try { bool saved = false; if (SessionHelper.Locator != null) { SessionHelper.Locator.CompanyId = model.CompanyId; SessionHelper.Locator.Description = string.IsNullOrEmpty(model.Description) ? "" : model.Description; SessionHelper.Locator.Id = model.Id; SessionHelper.Locator.SOBId = SessionHelper.SOBId; SessionHelper.Locator.Status = model.Status; LocatorHelper.Save(SessionHelper.Locator); SessionHelper.Locator = null; saved = true; } else { message = "No Locator information available!"; } return(Json(new { success = saved, message = message })); } catch (Exception e) { message = e.Message; return(Json(new { success = false, message = message })); } }
public ActionResult AddNewPartial(LocatorWarehouseModel model) { if (ModelState.IsValid) { try { bool validated = true; model.SOBId = SessionHelper.SOBId; if (SessionHelper.Locator != null) { if (SessionHelper.Locator.LocatorWarehouses != null && SessionHelper.Locator.LocatorWarehouses.Count > 0) { model.Id = SessionHelper.Locator.LocatorWarehouses.LastOrDefault().Id + 1; } else { model.Id = 1; } } else { model.Id = 1; } if (SessionHelper.Locator.LocatorWarehouses.Count > 0) { foreach (var item in SessionHelper.Locator.LocatorWarehouses) { if (model.StartDate <= item.EndDate || model.EndDate <= item.StartDate) { ViewData["EditError"] = "Dates are overlapping."; validated = false; } } } if (model.StartDate > model.EndDate) { ViewData["EditError"] = "End Date cannot be less than Start Date."; validated = false; } if (validated) { LocatorHelper.InsertLocatorWarehouse(model); } } catch (Exception e) { ViewData["EditError"] = e.Message; } } else { ViewData["EditError"] = "Please, correct all errors."; } return(PartialView("createPartial", LocatorHelper.GetLocatorWarehouses())); }
public virtual void Begin() { var factory = LocatorHelper.GetInstance <IUnitOfWorkFactory>(); unitOfWork = factory.Create(); unitOfWork.Begin(); }
private void FindElements() { this.sidebar = LocatorHelper.QuietlyFindElement(driver, sidebarLocator, 10); if (sidebar != null) { this.sortableListItem = LocatorHelper.QuietlyFindElementWithinElement(driver, sortableListItemLocator, this.sidebar, 10); } }
private void FindElements(IWebDriver driver) { AutoclosableSuccessMsgButton = LocatorHelper.QuietlyFindElement(driver, AutoclosableSuccessMsgButtonLocator, 10); NormalSuccessMsgButton = LocatorHelper.QuietlyFindElement(driver, NormalSuccessMsgButtonLocator, 10); AutoclosableWarningMsgButton = LocatorHelper.QuietlyFindElement(driver, AutoclosableWarningMsgButtonLocator, 10); NormalWarningMsgButton = LocatorHelper.QuietlyFindElement(driver, NormalWarningMsgButtonLocator, 10); AutoclosableDangerMsgButton = LocatorHelper.QuietlyFindElement(driver, AutoclosableDangerMsgButtonLocator, 10); NormalDangerMsgButton = LocatorHelper.QuietlyFindElement(driver, NormalDangerMsgButtonLocator, 10); AutoclosableInfoMsgButton = LocatorHelper.QuietlyFindElement(driver, AutoclosableInfoMsgButtonLocator, 10); NormalInfoMsgButton = LocatorHelper.QuietlyFindElement(driver, NormalInfoMsgButtonLocator, 10); }
public virtual void Validate(TEntity entity) { try { LocatorHelper.GetInstance <TValidator>().ValidateAndThrow(entity); } catch (ValidationException ex) { throw ex; } }
private void PerformServiceSelectionTest(BrowserType browserType) { // Initialize web driver IWebDriver webDriver = DriverUtilities.CreateDriver(browserType); Assert.IsNotNull(webDriver, "Could not acquire driver for :" + browserType); webDriver.Navigate().GoToUrl(LocatorHelper.HOME_PAGE_URL); // Accept all cookies IWebElement acceptAllCookiesButton = LocatorHelper.FindServicePageControl(webDriver, ServicePageLocatorName.AcceptAllCookies); acceptAllCookiesButton.Click(); // Click on Service in main menu IWebElement serviceMainMenu = LocatorHelper.FindServicePageControl(webDriver, ServicePageLocatorName.ServiceMainMenu); serviceMainMenu.Click(); // Click on Automation under Services IWebElement automationLink = LocatorHelper.FindServicePageControl(webDriver, ServicePageLocatorName.AutomationSubMenu); automationLink.Click(); // Verify the Automation title in tab window Assert.AreEqual(webDriver.Title, "Automation", "Missing the title 'Automation'"); // Verify the Automation title inside the page IWebElement automationHeader = LocatorHelper.FindServicePageControl(webDriver, ServicePageLocatorName.AutomationHeaderText); Assert.AreEqual(automationHeader.Text, "Automation", "Missing the header text 'Automation'"); // Hover to the Service menu item Actions hoverAction = new Actions(webDriver); serviceMainMenu = LocatorHelper.FindServicePageControl(webDriver, ServicePageLocatorName.ServiceMainMenu); hoverAction.MoveToElement(serviceMainMenu).Perform(); // Ensure Services and Automation links are selected string classAttributValue = serviceMainMenu.GetAttribute("class"); if (!classAttributValue.Contains("selected has-children expanded level2 hover")) { Assert.Fail("Service menu not selected and expanded"); } IWebElement automationLinkParent = LocatorHelper.FindServicePageControl(webDriver, ServicePageLocatorName.AutomationSubMenuParentLI); Assert.IsNotNull(automationLinkParent, "Automation sub menu is not selected"); // Close the web driver DriverUtilities.DisposeDriver(webDriver); }
public ActionResult Edit(string id) { LocatorModel model = LocatorHelper.GetLocator(id); model.LocatorWarehouses = LocatorHelper.GetLocatorWarehouses(id).ToList(); model.SOBId = SessionHelper.SOBId; model.CompanyId = AuthenticationHelper.CompanyId.Value; SessionHelper.Locator = model; return(View("Create", model)); }
public ActionResult Delete(string id) { try { LocatorHelper.Delete(id); return(RedirectToAction("Index")); } catch (Exception ex) { return(RedirectToAction("Index", new { message = ex.Message })); } }
void AddLocatorGroup() { LocatorHelper helper = target as LocatorHelper; if (helper == null) { return; } GameObject go = new GameObject("NewLocatorGroup"); go.AddComponent <LocatorGroup>(); go.transform.parent = helper.transform; }
public static By ByKeyName(this IEnumerable <Locator> locators, string pageName, string keyName, string parameter) { Thread.Sleep(1500); var loc = locators.GetLocatorByKeyName(pageName, keyName); return(LocatorHelper.GetWebDriverBy(new Locator { KeyName = loc.KeyName, ByType = loc.ByType, ByValue = string.Format(loc.ByValue, parameter), ByName = loc.ByName, Page = loc.Page, Description = loc.Description })); }
bool IsLocatorSupported() { try { if (!LocatorHelper.IsEnabledType(LocationType.Hybrid)) { Log.Error("Failed to start Locator. Please check if the Location setting on your device is On."); return(false); } } catch (NotSupportedException) { Log.Error("Platform Not Supported"); return(false); } return(true); }
public ActionResult DeletePartial(LocatorWarehouseModel model) { if (ModelState.IsValid) { try { LocatorModel header = SessionHelper.Locator; LocatorHelper.DeleteLocatorWarehouse(model); SessionHelper.Locator = header; IList <LocatorWarehouseModel> LocatorWarehouses = LocatorHelper.GetLocatorWarehouses(); return(PartialView("createPartial", LocatorWarehouses)); } catch (Exception e) { ViewData["EditError"] = e.Message; } } else { ViewData["EditError"] = "Please, correct all errors."; } return(PartialView("createPartial")); }
public static By ToWebDriverBy(this Locator locator) { return(LocatorHelper.GetWebDriverBy(locator)); }
private void PerformCountryTest(BrowserType browserType) { // Initialize the web driver IWebDriver webDriver = DriverUtilities.CreateDriver(browserType); Assert.IsNotNull(webDriver, "Could not acquire driver for :" + browserType); webDriver.Navigate().GoToUrl(LocatorHelper.HOME_PAGE_URL); // Accept all cookies IWebElement acceptAllCookiesButton = LocatorHelper.FindServicePageControl(webDriver, ServicePageLocatorName.AcceptAllCookies); acceptAllCookiesButton.Click(); // Open the countries drop down IWebElement dropDown = LocatorHelper.FindHomePageControl(webDriver, HomePageLocatorName.CountryDropDown); dropDown.Click(); // Fetch all country web elements IWebElement countryList = LocatorHelper.FindHomePageControl(webDriver, HomePageLocatorName.CountryList); IEnumerable <IWebElement> countryEntries = LocatorHelper.FindAllCountries(webDriver, countryList); string firstWindowHandle = webDriver.WindowHandles.First(); // Iterate each country web element (anchor) foreach (IWebElement countryEntry in countryEntries) { // Open a new Tab window for the country countryEntry.Click(); string countryName = countryEntry.Text; // Ensure a new Tab window has been opened string lastWindowHandle = webDriver.WindowHandles.Last(); Assert.AreNotEqual(firstWindowHandle, lastWindowHandle, "Could not open link for :" + countryName); // Switch the driver to newly opened tab window webDriver.SwitchTo().Window(lastWindowHandle); // Accept all cookies in the newly opened tab window acceptAllCookiesButton = LocatorHelper.FindServicePageControl(webDriver, ServicePageLocatorName.AcceptAllCookies); if (acceptAllCookiesButton != null) { acceptAllCookiesButton.Click(); } // Ensure that the newly opened tab window page has a valid Sogeti logo. IWebElement logo = LocatorHelper.FindHomePageControl(webDriver, HomePageLocatorName.SogetiLogo); if (logo == null) { logo = LocatorHelper.FindHomePageControl(webDriver, HomePageLocatorName.SogetiLogoNetherlands); } Assert.IsNotNull(logo, "Page not working for :" + countryName); // Close the newly opened tab window webDriver.Close(); // Switch the driver back to the original page webDriver.SwitchTo().Window(firstWindowHandle); } // Close the driver. DriverUtilities.DisposeDriver(webDriver); }
public LoginPage() { mobileGeneric = new MobileGeneric(); locatorHelper = new LocatorHelper(Driver, Config.OperatingSystem.ToLower()); PageFactory.InitElements(Driver, this); }
public void Begin() { contextManager = LocatorHelper.GetInstance <IContextManager>(); }
public static IWebElement Driver(this IEnumerable <Locator> locators, IWebDriver driver, string keyName) { Thread.Sleep(1500); return(driver.FindElement(LocatorHelper.GetWebDriverBy(locators.FirstOrDefault(t => t.KeyName.ToLower().Trim() == keyName.Trim().ToLower())))); }
private void PerformContactUsTest(BrowserType browserType) { // Initialize web driver IWebDriver webDriver = DriverUtilities.CreateDriver(browserType); Assert.IsNotNull(webDriver, "Could not acquire driver for :" + browserType); webDriver.Navigate().GoToUrl(LocatorHelper.HOME_PAGE_URL); // Accept all cookies IWebElement acceptAllCookiesButton = LocatorHelper.FindServicePageControl(webDriver, ServicePageLocatorName.AcceptAllCookies); acceptAllCookiesButton.Click(); // Navigate to services and automation page IWebElement serviceMainMenu = LocatorHelper.FindServicePageControl(webDriver, ServicePageLocatorName.ServiceMainMenu); serviceMainMenu.Click(); IWebElement automationLink = LocatorHelper.FindServicePageControl(webDriver, ServicePageLocatorName.AutomationSubMenu); automationLink.Click(); // Suffix to generate random texts string suffix = DateTime.Now.ToString("_yyyy_MM_dd_HH_mm_ss"); // Generate random texts for required fields IWebElement firstName = LocatorHelper.FindContactUsControl(webDriver, ContactUsLocatorName.FirstName); firstName.SendKeys("FirstName" + suffix); IWebElement lastName = LocatorHelper.FindContactUsControl(webDriver, ContactUsLocatorName.LastName); lastName.SendKeys("LastName" + suffix); IWebElement email = LocatorHelper.FindContactUsControl(webDriver, ContactUsLocatorName.EMail); email.SendKeys(suffix + "@a.com"); IWebElement phone = LocatorHelper.FindContactUsControl(webDriver, ContactUsLocatorName.Phone); phone.SendKeys("0049"); IWebElement country = LocatorHelper.FindContactUsControl(webDriver, ContactUsLocatorName.Country); country.SendKeys("Germany"); IWebElement message = LocatorHelper.FindContactUsControl(webDriver, ContactUsLocatorName.Message); message.SendKeys("some message" + suffix); // Click on Agree checkbox IWebElement agreement = LocatorHelper.FindContactUsControl(webDriver, ContactUsLocatorName.Agreement); agreement.Click(); // Note : Captcha stops the test run here. // Captcha has been introduced to stop the automated usage of website hence this does not let us to continue further. // Please see the following pseudo code. //IWebElement captcha = LocatorHelper.FindContactUsControl(webDriver, ContactUsLocatorName.Captcha); //IWebElement submit = LocatorHelper.FindContactUsControl(webDriver, ContactUsLocatorName.Submit); //submit.Click(); //IWebElement thankYouDiv = LocatorHelper.FindContactUsControl(webDriver, ContactUsLocatorName.ThankYou); //if (thankYouDiv == null || !thankYouDiv.Text.Contains("Thank you for contacting us.")) // Assert.Fail("Expected 'Thank you message' missing on Contact Us submit action"); // Exit the driver DriverUtilities.DisposeDriver(webDriver); }
public ActionResult CreatePartial() { return(PartialView("createPartial", LocatorHelper.GetLocatorWarehouses())); }
public ActionResult LocatorPartial(LocatorListModel model) { return(PartialView("_List", LocatorHelper.GetLocatorsCombo(SessionHelper.SOBId))); }
public static By ByKeyName(this IEnumerable <Locator> locators, string pageName, string keyName) { return(LocatorHelper.GetWebDriverBy(locators.GetLocatorByKeyName(pageName, keyName))); }