How to use Navigate method of Atata.AtataNavigator class

Best Atata code snippet using Atata.AtataNavigator.Navigate

AtataNavigator.cs

Source:AtataNavigator.cs Github

copy

Full Screen

...16 {17 _context = context.CheckNotNull(nameof(context));18 }19 /// <summary>20 /// Navigates to the specified page object.21 /// </summary>22 /// <typeparam name="T">The type of the page object.</typeparam>23 /// <param name="pageObject">24 /// The page object.25 /// If set to <see langword="null"/> creates an instance using the default constructor.</param>26 /// <param name="url">The URL.</param>27 /// <param name="navigate">If set to <see langword="true"/> executes page object navigation functionality.</param>28 /// <param name="temporarily">If set to <see langword="true"/> navigates temporarily preserving current page object state.</param>29 /// <returns>The page object.</returns>30 public T To<T>(T pageObject = null, string url = null, bool navigate = true, bool temporarily = false)31 where T : PageObject<T>32 {33 return To(pageObject, new GoOptions { Url = url, Navigate = string.IsNullOrWhiteSpace(url) && navigate, Temporarily = temporarily });34 }35 /// <summary>36 /// Navigates to the window with the specified page object by name.37 /// </summary>38 /// <typeparam name="T">The type of the page object.</typeparam>39 /// <param name="pageObject">40 /// The page object.41 /// If set to <see langword="null"/> creates an instance using the default constructor.</param>42 /// <param name="windowName">Name of the browser window.</param>43 /// <param name="temporarily">If set to <see langword="true"/> navigates temporarily preserving current page object state.</param>44 /// <returns>The page object.</returns>45 public T ToWindow<T>(T pageObject, string windowName, bool temporarily = false)46 where T : PageObject<T>47 {48 SetContextAsCurrent();49 _context.Log.Info($"Switch to \"{windowName}\" window");50 return To(pageObject, new GoOptions { Navigate = false, WindowName = windowName, Temporarily = temporarily });51 }52 /// <summary>53 /// Navigates to the window by name.54 /// </summary>55 /// <typeparam name="T">The type of the page object.</typeparam>56 /// <param name="windowName">Name of the browser window.</param>57 /// <param name="temporarily">If set to <see langword="true"/> navigates temporarily preserving current page object state.</param>58 /// <returns>The page object.</returns>59 public T ToWindow<T>(string windowName, bool temporarily = false)60 where T : PageObject<T>61 {62 SetContextAsCurrent();63 _context.Log.Info($"Switch to \"{windowName}\" window");64 return To<T>(null, new GoOptions { Navigate = false, WindowName = windowName, Temporarily = temporarily });65 }66 /// <summary>67 /// Navigates to the next window with the specified page object.68 /// </summary>69 /// <typeparam name="T">The type of the page object.</typeparam>70 /// <param name="pageObject">71 /// The page object.72 /// If set to <see langword="null"/> creates an instance using the default constructor.</param>73 /// <param name="temporarily">If set to <see langword="true"/> navigates temporarily preserving current page object state.</param>74 /// <returns>The page object.</returns>75 public T ToNextWindow<T>(T pageObject = null, bool temporarily = false)76 where T : PageObject<T>77 {78 SetContextAsCurrent();79 _context.Log.Info("Switch to next window");80 string currentWindowHandle = _context.Driver.CurrentWindowHandle;81 string nextWindowHandle = _context.Driver.WindowHandles.82 SkipWhile(x => x != currentWindowHandle).83 ElementAt(1);84 return To(pageObject, new GoOptions { Navigate = false, WindowName = nextWindowHandle, Temporarily = temporarily });85 }86 /// <summary>87 /// Navigates to the previous window with the specified page object.88 /// </summary>89 /// <typeparam name="T">The type of the page object.</typeparam>90 /// <param name="pageObject">91 /// The page object.92 /// If set to <see langword="null"/> creates an instance using the default constructor.</param>93 /// <param name="temporarily">If set to <see langword="true"/> navigates temporarily preserving current page object state.</param>94 /// <returns>The page object.</returns>95 public T ToPreviousWindow<T>(T pageObject = null, bool temporarily = false)96 where T : PageObject<T>97 {98 SetContextAsCurrent();99 _context.Log.Info("Switch to previous window");100 string currentWindowHandle = _context.Driver.CurrentWindowHandle;101 string previousWindowHandle = _context.Driver.WindowHandles102 .Reverse()103 .SkipWhile(x => x != currentWindowHandle)104 .ElementAt(1);105 return To(pageObject, new GoOptions { Navigate = false, WindowName = previousWindowHandle, Temporarily = temporarily });106 }107 private T To<T>(T pageObject, GoOptions options)108 where T : PageObject<T>109 {110 SetContextAsCurrent();111 var currentPageObject = _context.PageObject;112 return currentPageObject is null113 ? GoToInitialPageObject(pageObject, options)114 : GoToFollowingPageObject(currentPageObject, pageObject, options);115 }116 private T GoToInitialPageObject<T>(T pageObject, GoOptions options)117 where T : PageObject<T>118 {119 pageObject = pageObject ?? ActivatorEx.CreateInstance<T>();120 _context.PageObject = pageObject;121 if (!string.IsNullOrWhiteSpace(options.Url))122 ToUrl(options.Url);123 pageObject.NavigateOnInit = options.Navigate;124 pageObject.Init();125 return pageObject;126 }127 private T GoToFollowingPageObject<T>(128 UIComponent currentPageObject,129 T nextPageObject,130 GoOptions options)131 where T : PageObject<T>132 {133 bool isReturnedFromTemporary = TryResolvePreviousPageObjectNavigatedTemporarily(ref nextPageObject);134 nextPageObject = nextPageObject ?? ActivatorEx.CreateInstance<T>();135 if (!isReturnedFromTemporary)136 {137 if (!options.Temporarily)138 {139 _context.CleanUpTemporarilyPreservedPageObjectList();140 }141 nextPageObject.NavigateOnInit = options.Navigate;142 if (options.Temporarily)143 {144 nextPageObject.IsTemporarilyNavigated = options.Temporarily;145 _context.TemporarilyPreservedPageObjectList.Add(currentPageObject);146 }147 }148 ((IPageObject)currentPageObject).DeInit();149 _context.PageObject = nextPageObject;150 // TODO: Review this condition.151 if (!options.Temporarily)152 UIComponentResolver.CleanUpPageObject(currentPageObject);153 if (!string.IsNullOrWhiteSpace(options.Url))154 Go.ToUrl(options.Url);155 if (!string.IsNullOrWhiteSpace(options.WindowName))156 ((IPageObject)currentPageObject).SwitchToWindow(options.WindowName);157 if (isReturnedFromTemporary)158 {159 _context.Log.Info("Go to {0}", nextPageObject.ComponentFullName);160 }161 else162 {163 nextPageObject.PreviousPageObject = currentPageObject;164 nextPageObject.Init();165 }166 return nextPageObject;167 }168 private bool TryResolvePreviousPageObjectNavigatedTemporarily<TPageObject>(ref TPageObject pageObject)169 where TPageObject : PageObject<TPageObject>170 {171 var tempPageObjectsEnumerable = _context.TemporarilyPreservedPageObjects.172 AsEnumerable().173 Reverse().174 OfType<TPageObject>();175 TPageObject pageObjectReferenceCopy = pageObject;176 TPageObject foundPageObject = pageObject == null177 ? tempPageObjectsEnumerable.FirstOrDefault(x => x.GetType() == typeof(TPageObject))178 : tempPageObjectsEnumerable.FirstOrDefault(x => x == pageObjectReferenceCopy);179 if (foundPageObject == null)180 return false;181 pageObject = foundPageObject;182 var tempPageObjectsToRemove = _context.TemporarilyPreservedPageObjects.183 SkipWhile(x => x != foundPageObject).184 ToArray();185 UIComponentResolver.CleanUpPageObjects(tempPageObjectsToRemove.Skip(1));186 foreach (var item in tempPageObjectsToRemove)187 _context.TemporarilyPreservedPageObjectList.Remove(item);188 return true;189 }190 /// <summary>191 /// Navigates to the specified URL.192 /// </summary>193 /// <param name="url">The URL.</param>194 public void ToUrl(string url)195 {196 SetContextAsCurrent();197 if (!UriUtils.TryCreateAbsoluteUrl(url, out Uri absoluteUrl))198 {199 if (!_context.IsNavigated && _context.BaseUrl is null)200 {201 if (string.IsNullOrWhiteSpace(url))202 throw new InvalidOperationException("Cannot navigate to empty or null URL. AtataContext.Current.BaseUrl can be set with base URL.");203 else204 throw new InvalidOperationException($"Cannot navigate to relative URL \"{url}\". AtataContext.Current.BaseUrl can be set with base URL.");205 }206 if (_context.BaseUrl is null)207 {208 Uri currentUri = new Uri(_context.Driver.Url, UriKind.Absolute);209 string domainPart = currentUri.GetComponents(UriComponents.SchemeAndServer | UriComponents.UserInfo, UriFormat.Unescaped);210 Uri domainUri = new Uri(domainPart);211 absoluteUrl = new Uri(domainUri, url);212 }213 else214 {215 absoluteUrl = UriUtils.Concat(_context.BaseUrl, url);216 }217 }218 Navigate(absoluteUrl);219 }220 private void Navigate(Uri uri)221 {222 _context.Log.Info($"Go to URL \"{uri}\"");223 _context.Driver.Navigate().GoToUrl(uri);224 _context.IsNavigated = true;225 }226 private void SetContextAsCurrent()227 {228 AtataContext.Current = _context;229 }230 }231}...

Full Screen

Full Screen

Go.cs

Source:Go.cs Github

copy

Full Screen

1namespace Atata2{3 /// <summary>4 /// Provides the navigation functionality between pages and windows.5 /// </summary>6 public static class Go7 {8 /// <inheritdoc cref="AtataNavigator.To{T}(T, string, bool, bool)"/>9 public static T To<T>(T pageObject = null, string url = null, bool navigate = true, bool temporarily = false)10 where T : PageObject<T>11 =>12 ResolveAtataContext().Go.To(pageObject, url, navigate, temporarily);1314 /// <inheritdoc cref="AtataNavigator.ToWindow{T}(T, string, bool)"/>15 public static T ToWindow<T>(T pageObject, string windowName, bool temporarily = false)16 where T : PageObject<T>17 =>18 ResolveAtataContext().Go.ToWindow(pageObject, windowName, temporarily);1920 /// <inheritdoc cref="AtataNavigator.ToWindow{T}(string, bool)"/>21 public static T ToWindow<T>(string windowName, bool temporarily = false)22 where T : PageObject<T>23 =>24 ResolveAtataContext().Go.ToWindow<T>(windowName, temporarily);2526 /// <inheritdoc cref="AtataNavigator.ToNextWindow{T}(T, bool)"/>27 public static T ToNextWindow<T>(T pageObject = null, bool temporarily = false)28 where T : PageObject<T>29 =>30 ResolveAtataContext().Go.ToNextWindow(pageObject, temporarily);3132 /// <inheritdoc cref="AtataNavigator.ToPreviousWindow{T}(T, bool)"/>33 public static T ToPreviousWindow<T>(T pageObject = null, bool temporarily = false)34 where T : PageObject<T>35 =>36 ResolveAtataContext().Go.ToPreviousWindow(pageObject, temporarily);3738 /// <inheritdoc cref="AtataNavigator.ToUrl(string)"/>39 public static void ToUrl(string url) =>40 ResolveAtataContext().Go.ToUrl(url);4142 private static AtataContext ResolveAtataContext() =>43 AtataContext.Current44 ?? AtataContext.Configure().Build();45 }46} ...

Full Screen

Full Screen

Navigate

Using AI Code Generation

copy

Full Screen

1using Atata;2using NUnit.Framework;3{4 {5 public void Test()6 {7 AtataContext.Configure()8 .UseChrome()9 .UseNUnitTestName()10 .Build();11 Go.To<HomePage>();12 Go.To<FeaturesPage>();13 Go.To<DownloadPage>();14 Go.To<DocumentationPage>();15 Go.To<BlogPage>();16 Go.To<CommunityPage>();17 Go.To<AboutPage>();18 Go.To<ContactPage>();19 Go.To<HomePage>();20 }21 }22}23using Atata;24using NUnit.Framework;25{26 {27 public void Test()28 {29 AtataContext.Configure()30 .UseChrome()31 .UseNUnitTestName()32 .Build();33 AtataContext.Current.Go.To<HomePage>();34 AtataContext.Current.Go.To<FeaturesPage>();35 AtataContext.Current.Go.To<DownloadPage>();36 AtataContext.Current.Go.To<DocumentationPage>();37 AtataContext.Current.Go.To<BlogPage>();38 AtataContext.Current.Go.To<CommunityPage>();39 AtataContext.Current.Go.To<AboutPage>();40 AtataContext.Current.Go.To<ContactPage>();41 AtataContext.Current.Go.To<HomePage>();42 }43 }44}45using Atata;46using NUnit.Framework;47{48 {49 public void Test()50 {51 AtataContext.Configure()52 .UseChrome()53 .UseNUnitTestName()54 .Build();55 AtataContext.Current.Go.ToUrl("/features/");56 AtataContext.Current.Go.ToUrl("/download/");57 AtataContext.Current.Go.ToUrl("/documentation/");58 AtataContext.Current.Go.ToUrl("/blog/");59 AtataContext.Current.Go.ToUrl("/community/");60 AtataContext.Current.Go.ToUrl("/about/");61 AtataContext.Current.Go.ToUrl("/contact

Full Screen

Full Screen

Navigate

Using AI Code Generation

copy

Full Screen

1using Atata;2{3 using _ = HomePage;4 {5 public Header Header { get; private set; }6 public Footer Footer { get; private set; }7 public SearchSection Search { get; private set; }8 public ProductsSection Products { get; private set; }9 {10 public Link<HomePage, _> Logo { get; private set; }11 }12 {13 public Link<HomePage, _> Logo { get; private set; }14 }15 {16 public TextInput<_> SearchField { get; private set; }17 public Button<SearchResultPage, _> SearchButton { get; private set; }18 }19 {20 public Link<ProductDetailsPage, _> Product1 { get; private set; }21 public Link<ProductDetailsPage, _> Product2 { get; private set; }22 public Link<ProductDetailsPage, _> Product3 { get; private set; }23 }24 }25}26using Atata;27{28 using _ = SearchResultPage;29 [Url("search")]30 {31 public Header Header { get; private set; }32 public Footer Footer { get; private set; }33 public SearchSection Search { get; private set; }34 public ProductsSection Products { get; private set; }35 {36 public Link<HomePage, _> Logo { get; private set; }37 }38 {39 public Link<HomePage, _> Logo { get; private set; }40 }41 {42 public TextInput<_> SearchField { get; private set; }43 public Button<SearchResultPage, _> SearchButton { get; private set; }44 }45 {46 public Link<ProductDetailsPage, _> Product1 { get; private set; }

Full Screen

Full Screen

Navigate

Using AI Code Generation

copy

Full Screen

1{2 using _ = Page2;3 [Url("Page2")]4 {5 public H1<_> Heading { get; private set; }6 public ButtonDelegate<_> Back { get; private set; }7 }8}9{10 using _ = Page3;11 [Url("Page3")]12 {13 public H1<_> Heading { get; private set; }14 public ButtonDelegate<_> Back { get; private set; }15 }16}17{18 using _ = Page4;19 [Url("Page4")]20 {21 public H1<_> Heading { get; private set; }22 public ButtonDelegate<_> Back { get; private set; }23 }24}25{26 using _ = Page5;27 [Url("Page5")]28 {29 public H1<_> Heading { get; private set; }30 public ButtonDelegate<_> Back { get; private set; }31 }32}33{34 using _ = Page6;35 [Url("Page6")]36 {37 public H1<_> Heading { get; private set; }38 public ButtonDelegate<_> Back { get; private set; }39 }40}41{42 using _ = Page7;43 [Url("Page7")]44 {45 public H1<_> Heading { get; private set; }46 public ButtonDelegate<_> Back { get; private set; }47 }48}

Full Screen

Full Screen

Navigate

Using AI Code Generation

copy

Full Screen

1using Atata;2{3 {4 public void Navigate(string url)5 {6 AtataContext.Current.Driver.Navigate().GoToUrl(url);7 }8 }9}10using Atata;11{12 {13 public void GoTo<TPageObject>() where TPageObject : PageObject<TPageObject>14 {15 AtataContext.Current.Driver.Navigate().GoToUrl(AtataContext.Current.BaseUrl + PageUrlAttribute.GetUrl<TPageObject>());16 }17 }18}19using Atata;20{21 {22 public void GoTo<TPageObject>(string url) where TPageObject : PageObject<TPageObject>23 {24 AtataContext.Current.Driver.Navigate().GoToUrl(AtataContext.Current.BaseUrl + url);25 }26 }27}28using Atata;29{30 {31 public void GoTo<TPageObject>(string url, string query) where TPageObject : PageObject<TPageObject>32 {33 AtataContext.Current.Driver.Navigate().GoToUrl(AtataContext.Current.BaseUrl + url + query);34 }35 }36}37using Atata;38{39 {40 public void GoTo<TPageObject>(string url, string query, string fragment) where TPageObject : PageObject<TPageObject>41 {42 AtataContext.Current.Driver.Navigate().GoToUrl(AtataContext.Current.BaseUrl + url + query + fragment);43 }44 }45}46using Atata;47{48 {49 public void GoTo<TPageObject>(string url, string query, string fragment, int port) where TPageObject : PageObject<TPage

Full Screen

Full Screen

Navigate

Using AI Code Generation

copy

Full Screen

1using Atata;2{3 {4 public H1<_2> Header { get; private set; }5 }6}7@{8 Layout = null;9}10@{11 ViewBag.Title = "Page 2";12}13@{14 var header = new Atata.H1<_2>(this);15}16using Atata;17{18 {19 public H1<HomePage> Header { get; private set; }20 [FindByClass("nav")]21 public NavigationMenu<HomePage> NavigationMenu { get; private set; }22 }23}24@{25 Layout = null;26}27@{28 ViewBag.Title = "Home Page";29}30@{31 var header = new Atata.H1<HomePage>(this);32}33using Atata;34{35 {36 }37}38using Atata;39{40 {41 [FindByClass("active")]42 public Control<TOwner> Active { get; private set; }43 [FindByClass("disabled")]44 public Control<TOwner> Disabled {

Full Screen

Full Screen

Navigate

Using AI Code Generation

copy

Full Screen

1using Atata;2using NUnit.Framework;3{4 {5 public void Test1()6 {7 Go.To<HomePage>()8 .Header.Should.Equal("Sample App");9 }10 }11}12using Atata;13using NUnit.Framework;14{15 {16 public void Test1()17 {18 Go.To<HomePage>()19 .Header.Should.Equal("Sample App");20 }21 }22}23using Atata;24using NUnit.Framework;25{26 {27 public void Test1()28 {29 Go.ToUrl("/Home")30 .Header.Should.Equal("Sample App");31 }32 }33}34using Atata;35using NUnit.Framework;36{37 {38 public void Test1()39 {40 Go.ToUrl("/Home")41 .Header.Should.Equal("Sample App");42 }43 }44}45using Atata;46using NUnit.Framework;47{48 {49 public void Test1()50 {51 Go.ToUrl("/Home")52 .Header.Should.Equal("Sample App");53 }54 }55}56using Atata;57using NUnit.Framework;58{59 {

Full Screen

Full Screen

Navigate

Using AI Code Generation

copy

Full Screen

1 public void TestMethod1()2{3 Build();4 AtataContext.Current.LogNUnitInfo();5 AtataContext.Current.LogNUnitInfo();6 AtataContext.Current.LogNUnitInfo();7 AtataContext.Current.LogNUnitInfo();8 AtataContext.Current.LogNUnitInfo();9 AtataContext.Current.LogNUnitInfo();10 AtataContext.Current.LogNUnitInfo();11 AtataContext.Current.LogNUnitInfo();12 AtataContext.Current.LogNUnitInfo();13 AtataContext.Current.LogNUnitInfo();14 AtataContext.Current.LogNUnitInfo();15 AtataContext.Current.LogNUnitInfo();16 AtataContext.Current.LogNUnitInfo();17 AtataContext.Current.LogNUnitInfo();18 AtataContext.Current.LogNUnitInfo();19 AtataContext.Current.LogNUnitInfo();

Full Screen

Full Screen

Navigate

Using AI Code Generation

copy

Full Screen

1Atata.AtataContext.Current.Go.To<Page1>();2Atata.AtataContext.Current.Go.ToUrl<Page1>();3Atata.AtataContext.Current.Go.To<Page1>("1");4Atata.AtataContext.Current.Go.ToUrl<Page1>("1");5Atata.AtataContext.Current.Go.To<Page1>(new { id = 1 });6Atata.AtataContext.Current.Go.ToUrl<Page1>(new { id = 1 });7Atata.AtataContext.Current.Go.To<Page1>("1", new { id = 1 });

Full Screen

Full Screen

Navigate

Using AI Code Generation

copy

Full Screen

1PageObject pageObject = new PageObject();2PageObject pageObject = new PageObject();3PageObject pageObject = new PageObject();4pageObject.NavigateTo<PageObject>();5PageObject pageObject = new PageObject();6pageObject.NavigateTo();7PageObject pageObject = new PageObject();8PageObject pageObject = new PageObject();9PageObject pageObject = new PageObject();10pageObject.NavigateTo<PageObject>();11PageObject pageObject = new PageObject();12pageObject.NavigateTo();13PageObject pageObject = new PageObject();14PageObject pageObject = new PageObject();15PageObject pageObject = new PageObject();16pageObject.NavigateTo<PageObject>();17PageObject pageObject = new PageObject();18pageObject.NavigateTo();19PageObject pageObject = new PageObject();

Full Screen

Full Screen

Navigate

Using AI Code Generation

copy

Full Screen

1AtataContext.Current.Navigate<PageObject>("/path/to/page");2Console.WriteLine(AtataContext.Current.PageObject<PageObject>().PageUrl);3Console.WriteLine(AtataContext.Current.PageObject<PageObject>().PageTitle);4Console.WriteLine(AtataContext.Current.PageObject<PageObject>().PageSource);5AtataContext.Current.Navigate<PageObject>("/path/to/page", (PageObject pageObject) =>6{7 Console.WriteLine(pageObject.PageUrl);8 Console.WriteLine(pageObject.PageTitle);9 Console.WriteLine(pageObject.PageSource);10});11AtataContext.Current.Navigate<PageObject>("/path/to/page", (PageObject pageObject) =>12{13 Console.WriteLine(pageObject.PageUrl);14 Console.WriteLine(pageObject.PageTitle);15 Console.WriteLine(pageObject.PageSource);16}, (PageObject pageObject) =>17{18 Console.WriteLine(pageObject.PageUrl);19 Console.WriteLine(pageObject.PageTitle);20 Console.WriteLine(pageObject.PageSource);21});22AtataContext.Current.Navigate<PageObject>("/path/to/page

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Atata automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Most used method in AtataNavigator

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful