private T To <T>(T pageObject, GoOptions options) where T : PageObject <T> { if (context.PageObject is null) { pageObject = pageObject ?? ActivatorEx.CreateInstance <T>(); context.PageObject = pageObject; if (!string.IsNullOrWhiteSpace(options.Url)) { ToUrl(options.Url); } pageObject.NavigateOnInit = options.Navigate; pageObject.Init(); return(pageObject); } else { IPageObject currentPageObject = (IPageObject)context.PageObject; T newPageObject = currentPageObject.GoTo(pageObject, options); context.PageObject = newPageObject; return(newPageObject); } }
private static T To <T>(T pageObject, GoOptions options) where T : PageObject <T> { if (AtataContext.Current == null) { AtataContext.Build().SetUp(); } if (AtataContext.Current.PageObject == null) { pageObject = pageObject ?? ActivatorEx.CreateInstance <T>(); AtataContext.Current.PageObject = pageObject; if (!string.IsNullOrWhiteSpace(options.Url)) { ToUrl(options.Url); } pageObject.NavigateOnInit = options.Navigate; pageObject.Init(); return(pageObject); } else { IPageObject currentPageObject = (IPageObject)AtataContext.Current.PageObject; T newPageObject = currentPageObject.GoTo(pageObject, options); AtataContext.Current.PageObject = newPageObject; return(newPageObject); } }
private T GoToFollowingPageObject <T>( UIComponent currentPageObject, T nextPageObject, GoOptions options) where T : PageObject <T> { bool isReturnedFromTemporary = TryResolvePreviousPageObjectNavigatedTemporarily(ref nextPageObject); nextPageObject = nextPageObject ?? ActivatorEx.CreateInstance <T>(); if (!isReturnedFromTemporary) { if (!options.Temporarily) { _context.CleanUpTemporarilyPreservedPageObjectList(); } nextPageObject.NavigateOnInit = options.Navigate; if (options.Temporarily) { nextPageObject.IsTemporarilyNavigated = options.Temporarily; _context.TemporarilyPreservedPageObjectList.Add(currentPageObject); } } ((IPageObject)currentPageObject).DeInit(); _context.PageObject = nextPageObject; // TODO: Review this condition. if (!options.Temporarily) { UIComponentResolver.CleanUpPageObject(currentPageObject); } if (!string.IsNullOrWhiteSpace(options.Url)) { Go.ToUrl(options.Url); } if (!string.IsNullOrWhiteSpace(options.WindowName)) { ((IPageObject)currentPageObject).SwitchToWindow(options.WindowName); } if (isReturnedFromTemporary) { _context.Log.Info("Go to {0}", nextPageObject.ComponentFullName); } else { nextPageObject.PreviousPageObject = currentPageObject; nextPageObject.Init(); } return(nextPageObject); }
private T To <T>(T pageObject, GoOptions options) where T : PageObject <T> { SetContextAsCurrent(); var currentPageObject = _context.PageObject; return(currentPageObject is null ? GoToInitialPageObject(pageObject, options) : GoToFollowingPageObject(currentPageObject, pageObject, options)); }
TOther IPageObject.GoTo <TOther>(TOther pageObject, GoOptions options) { bool isReturnedFromTemporary = TryResolvePreviousPageObjectNavigatedTemporarily(ref pageObject); pageObject = pageObject ?? ActivatorEx.CreateInstance <TOther>(); if (!isReturnedFromTemporary) { if (!options.Temporarily) { AtataContext.Current.CleanUpTemporarilyPreservedPageObjectList(); } pageObject.NavigateOnInit = options.Navigate; if (options.Temporarily) { pageObject.IsTemporarilyNavigated = options.Temporarily; AtataContext.Current.TemporarilyPreservedPageObjectList.Add(this); } } ExecuteTriggers(TriggerEvents.DeInit); // TODO: Review that condition. if (!options.Temporarily) { UIComponentResolver.CleanUpPageObject(this); } if (!string.IsNullOrWhiteSpace(options.Url)) { Go.ToUrl(options.Url); } if (!string.IsNullOrWhiteSpace(options.WindowName)) { SwitchTo(options.WindowName); } if (isReturnedFromTemporary) { Log.Info("Go to {0}", pageObject.ComponentFullName); } else { pageObject.PreviousPageObject = this; pageObject.Init(); } return(pageObject); }
private T GoToInitialPageObject <T>(T pageObject, GoOptions options) where T : PageObject <T> { pageObject = pageObject ?? ActivatorEx.CreateInstance <T>(); _context.PageObject = pageObject; if (!string.IsNullOrWhiteSpace(options.Url)) { ToUrl(options.Url); } pageObject.NavigateOnInit = options.Navigate; pageObject.Init(); return(pageObject); }