Best Atata code snippet using Atata.AtataNavigator
AtataContext.cs
Source:AtataContext.cs
...45 public static readonly TimeSpan DefaultRetryInterval = TimeSpan.FromSeconds(0.5);4647 internal AtataContext()48 {49 Go = new AtataNavigator(this);50 }5152 /// <summary>53 /// Gets or sets the current context.54 /// </summary>55 public static AtataContext Current56 {57 get58 {59 return ModeOfCurrent == AtataContextModeOfCurrent.ThreadStatic60 ? s_currentThreadStaticContext61 : ModeOfCurrent == AtataContextModeOfCurrent.AsyncLocal62 ? s_currentAsyncLocalContext.Value63 : s_currentStaticContext;64 }6566 set67 {68 if (ModeOfCurrent == AtataContextModeOfCurrent.ThreadStatic)69 s_currentThreadStaticContext = value;70 else if (ModeOfCurrent == AtataContextModeOfCurrent.AsyncLocal)71 s_currentAsyncLocalContext.Value = value;72 else73 s_currentStaticContext = value;74 }75 }7677 /// <summary>78 /// Gets or sets the mode of <see cref="Current"/> property.79 /// The default value is <see cref="AtataContextModeOfCurrent.AsyncLocal"/>.80 /// </summary>81 public static AtataContextModeOfCurrent ModeOfCurrent82 {83 get => s_modeOfCurrent;84 set85 {86 s_modeOfCurrent = value;8788 RetrySettings.ThreadBoundary = value == AtataContextModeOfCurrent.ThreadStatic89 ? RetrySettingsThreadBoundary.ThreadStatic90 : value == AtataContextModeOfCurrent.AsyncLocal91 ? RetrySettingsThreadBoundary.AsyncLocal92 : RetrySettingsThreadBoundary.Static;93 }94 }9596 /// <summary>97 /// Gets the global configuration.98 /// </summary>99 public static AtataContextBuilder GlobalConfiguration { get; } = new AtataContextBuilder(new AtataBuildingContext());100101 /// <summary>102 /// Gets the build start local date and time.103 /// Contains the same value for all the tests being executed within one build.104 /// </summary>105 public static DateTime? BuildStart { get; private set; }106107 /// <summary>108 /// Gets the build start UTC date and time.109 /// Contains the same value for all the tests being executed within one build.110 /// </summary>111 public static DateTime? BuildStartUtc { get; private set; }112113 // TODO: Review BuildStartInTimeZone property.114 internal DateTime BuildStartInTimeZone { get; private set; }115116 internal IDriverFactory DriverFactory { get; set; }117118 /// <summary>119 /// Gets the driver.120 /// </summary>121 public IWebDriver Driver122 {123 get124 {125 switch (DriverInitializationStage)126 {127 case AtataContextDriverInitializationStage.Build:128 return _driver;129 case AtataContextDriverInitializationStage.OnDemand:130 if (_driver is null)131 InitDriver();132 return _driver;133 default:134 return null;135 }136 }137 }138139 /// <summary>140 /// Gets a value indicating whether this instance has <see cref="Driver"/> instance.141 /// </summary>142 public bool HasDriver => _driver != null;143 /// <summary>144 /// Gets the driver alias.145 /// </summary>146 public string DriverAlias { get; internal set; }147148 /// <summary>149 /// Gets the driver initialization stage.150 /// </summary>151 public AtataContextDriverInitializationStage DriverInitializationStage { get; internal set; }152 /// <summary>153 /// Gets the instance of the log manager.154 /// </summary>155 public ILogManager Log { get; internal set; }156157 /// <summary>158 /// Gets the name of the test.159 /// </summary>160 public string TestName161 {162 get => _testName;163 internal set164 {165 _testName = value;166 TestNameSanitized = value.SanitizeForFileName();167 }168 }169170 /// <summary>171 /// Gets the name of the test sanitized for file path/name.172 /// </summary>173 public string TestNameSanitized { get; private set; }174175 /// <summary>176 /// Gets the name of the test suite (fixture/class).177 /// </summary>178 public string TestSuiteName179 {180 get => _testSuiteName;181 internal set182 {183 _testSuiteName = value;184 TestSuiteNameSanitized = value.SanitizeForFileName();185 }186 }187188 /// <summary>189 /// Gets the name of the test suite sanitized for file path/name.190 /// </summary>191 public string TestSuiteNameSanitized { get; private set; }192193 /// <summary>194 /// Gets the test suite (fixture/class) type.195 /// </summary>196 public Type TestSuiteType { get; internal set; }197198 /// <summary>199 /// Gets the local date/time of the start.200 /// </summary>201 public DateTime StartedAt { get; private set; }202203 /// <summary>204 /// Gets the UTC date/time of the start.205 /// </summary>206 public DateTime StartedAtUtc { get; private set; }207208 /// <summary>209 /// Gets the time zone.210 /// The default value is <see cref="TimeZoneInfo.Local"/>.211 /// </summary>212 public TimeZoneInfo TimeZone { get; internal set; }213214 /// <summary>215 /// Gets or sets the base URL.216 /// </summary>217 public string BaseUrl { get; set; }218219 /// <summary>220 /// Gets the base retry timeout.221 /// The default value is <c>5</c> seconds.222 /// </summary>223 public TimeSpan BaseRetryTimeout { get; internal set; }224225 /// <summary>226 /// Gets the base retry interval.227 /// The default value is <c>500</c> milliseconds.228 /// </summary>229 public TimeSpan BaseRetryInterval { get; internal set; }230231 /// <summary>232 /// Gets the element find timeout.233 /// The default value is <c>5</c> seconds.234 /// </summary>235 public TimeSpan ElementFindTimeout { get; internal set; }236237 /// <summary>238 /// Gets the element find retry interval.239 /// The default value is <c>500</c> milliseconds.240 /// </summary>241 public TimeSpan ElementFindRetryInterval { get; internal set; }242243 /// <summary>244 /// Gets the waiting timeout.245 /// The default value is <c>5</c> seconds.246 /// </summary>247 public TimeSpan WaitingTimeout { get; internal set; }248249 /// <summary>250 /// Gets the waiting retry interval.251 /// The default value is <c>500</c> milliseconds.252 /// </summary>253 public TimeSpan WaitingRetryInterval { get; internal set; }254255 /// <summary>256 /// Gets the verification timeout.257 /// The default value is <c>5</c> seconds.258 /// </summary>259 public TimeSpan VerificationTimeout { get; internal set; }260261 /// <summary>262 /// Gets the verification retry interval.263 /// The default value is <c>500</c> milliseconds.264 /// </summary>265 public TimeSpan VerificationRetryInterval { get; internal set; }266267 /// <summary>268 /// Gets the default control visibility.269 /// The default value is <see cref="Visibility.Any"/>.270 /// </summary>271 public Visibility DefaultControlVisibility { get; internal set; }272273 /// <summary>274 /// Gets the culture.275 /// The default value is <see cref="CultureInfo.CurrentCulture"/>.276 /// </summary>277 public CultureInfo Culture { get; internal set; }278279 /// <summary>280 /// Gets the type of the assertion exception.281 /// The default value is a type of <see cref="AssertionException"/>.282 /// </summary>283 public Type AssertionExceptionType { get; internal set; }284285 /// <summary>286 /// Gets the type of the aggregate assertion exception.287 /// The default value is a type of <see cref="AggregateAssertionException"/>.288 /// The exception type should have public constructor with <c>IEnumerable<AssertionResult></c> argument.289 /// </summary>290 public Type AggregateAssertionExceptionType { get; internal set; }291292 /// <summary>293 /// Gets the aggregate assertion strategy.294 /// The default value is an instance of <see cref="AtataAggregateAssertionStrategy"/>.295 /// </summary>296 public IAggregateAssertionStrategy AggregateAssertionStrategy { get; internal set; }297298 /// <summary>299 /// Gets the aggregate assertion depth level.300 /// </summary>301 public int AggregateAssertionLevel { get; internal set; }302303 /// <summary>304 /// Gets the strategy for warning assertion reporting.305 /// The default value is an instance of <see cref="AtataWarningReportStrategy"/>.306 /// </summary>307 public IWarningReportStrategy WarningReportStrategy { get; internal set; }308309 /// <summary>310 /// Gets the list of all assertion results.311 /// </summary>312 public List<AssertionResult> AssertionResults { get; } = new List<AssertionResult>();313314 /// <summary>315 /// Gets the list of pending assertion results with <see cref="AssertionStatus.Failed"/> or <see cref="AssertionStatus.Warning"/> status.316 /// </summary>317 public List<AssertionResult> PendingFailureAssertionResults { get; } = new List<AssertionResult>();318319 /// <summary>320 /// Gets the context of the attributes.321 /// </summary>322 public AtataAttributesContext Attributes { get; internal set; }323324 /// <summary>325 /// Gets the <see cref="DirectorySubject"/> of Artifacts directory.326 /// Artifacts directory can contain any files produced during test execution, logs, screenshots, downloads, etc.327 /// The default Artifacts directory path is <c>"{basedir}/artifacts/{build-start:yyyyMMddTHHmmss}{test-suite-name-sanitized:/*}{test-name-sanitized:/*}"</c>.328 /// </summary>329 public DirectorySubject Artifacts { get; internal set; }330331 /// <summary>332 /// Gets the <see cref="AtataNavigator"/> instance,333 /// which provides the navigation functionality between pages and windows.334 /// </summary>335 public AtataNavigator Go { get; }336337 /// <summary>338 /// Gets the current page object.339 /// </summary>340 public UIComponent PageObject { get; internal set; }341342 internal List<UIComponent> TemporarilyPreservedPageObjectList { get; private set; } = new List<UIComponent>();343344 internal bool IsNavigated { get; set; }345346 internal Stopwatch ExecutionStopwatch { get; } = Stopwatch.StartNew();347348 internal Stopwatch PureExecutionStopwatch { get; } = new Stopwatch();349
...
AtataNavigator.cs
Source:AtataNavigator.cs
...4{5 /// <summary>6 /// Represents the navigation functionality between pages and windows.7 /// </summary>8 public class AtataNavigator9 {10 private readonly AtataContext _context;11 /// <summary>12 /// Initializes a new instance of the <see cref="AtataNavigator"/> class.13 /// </summary>14 /// <param name="context">The context.</param>15 public AtataNavigator(AtataContext context)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>...
Go.cs
Source:Go.cs
...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}
...
AtataNavigator
Using AI Code Generation
1using Atata;2using NUnit.Framework;3{4 {5 public void SetUp()6 {7 }8 public void TearDown()9 {10 AtataContext.Current?.CleanUp();11 }12 }13}14using Atata;15using NUnit.Framework;16{17 {18 public void SetUp()19 {20 }21 public void TearDown()22 {23 AtataContext.Current?.CleanUp();24 }25 }26}27using Atata;28using NUnit.Framework;29{30 {31 public void SetUp()32 {33 }34 public void TearDown()35 {36 AtataContext.Current?.CleanUp();37 }38 }39}40using Atata;41using NUnit.Framework;42{43 {44 public void SetUp()45 {46 }47 public void TearDown()48 {49 AtataContext.Current?.CleanUp();50 }51 }52}53using Atata;54using NUnit.Framework;55{56 {57 public void SetUp()58 {59 }
AtataNavigator
Using AI Code Generation
1using Atata;2using NUnit.Framework;3{4 {5 public void Test()6 {7 AtataContext.Configure()8 .UseChrome()9 .AddNUnitTestContextLogging()10 .Build();11 Go.To<GooglePage>();12 AtataContext.Current.LogScreenshot();13 }14 }15}16using Atata;17using NUnit.Framework;18{19 {20 public void Test()21 {22 AtataContext.Configure()23 .UseChrome()24 .AddNUnitTestContextLogging()25 .Build();26 AtataContext.Current.Go.To<GooglePage>();27 AtataContext.Current.LogScreenshot();28 }29 }30}31using Atata;32using NUnit.Framework;33{34 {35 public void Test()36 {37 AtataContext.Configure()38 .UseChrome()39 .AddNUnitTestContextLogging()40 .Build();41 AtataContext.Current.LogScreenshot();42 }43 }44}45using Atata;46using NUnit.Framework;47{48 {49 public void Test()50 {51 AtataContext.Configure()52 .UseChrome()53 .AddNUnitTestContextLogging()54 .Build();55 AtataContext.Current.LogScreenshot();56 }57 }58}59using Atata;60using NUnit.Framework;61{62 {63 public void Test()64 {65 AtataContext.Configure()66 .UseChrome()
AtataNavigator
Using AI Code Generation
1using OpenQA.Selenium;2using OpenQA.Selenium.Chrome;3using Atata;4using NUnit.Framework;5{6 {7 public void Setup()8 {9 }10 public void Test1()11 {12 Go.To<HomePage>();13 }14 }15 {16 [FindById("search")]17 public TextInput<_> Search { get; private set; }18 }19}20using OpenQA.Selenium;21using OpenQA.Selenium.Chrome;22using Atata;23using NUnit.Framework;24{25 {26 public void Setup()27 {28 }29 public void Test1()30 {31 Build();32 AtataContext.Current.Log.StartSession();33 Go.To<HomePage>();34 AtataContext.Current.Log.EndSession();35 }36 }37 {38 [FindById("search")]39 public TextInput<_> Search { get; private set; }40 }41}42using OpenQA.Selenium;43using OpenQA.Selenium.Chrome;44using Atata;45using NUnit.Framework;46{47 {48 public void Setup()49 {50 }51 public void Test1()52 {53 Build();54 AtataContext.Current.Log.StartSession();55 Search.Set("Atata Framework");56 AtataContext.Current.Log.EndSession();57 }58 }59 {60 [FindById("search")]61 public TextInput<_> Search { get; private set; }62 }63}64using OpenQA.Selenium;65using OpenQA.Selenium.Chrome;66using Atata;67using NUnit.Framework;68{69 {70 public void Setup()71 {72 }
AtataNavigator
Using AI Code Generation
1using Atata;2using NUnit.Framework;3{4 {5 public void Test()6 {7 Build();8 Go.To<GooglePage>();9 searchPage.SearchField.Set("Atata");10 searchPage.SearchButton.Click();11 }12 }13}14using Atata;15using NUnit.Framework;16{17 {18 public void Test()19 {20 Go.To<GooglePage>();21 searchPage.SearchField.Set("Atata");22 searchPage.SearchButton.Click();23 }24 }25}26using Atata;27using NUnit.Framework;28{29 {30 public void Test()31 {32 Go.To<GooglePage>();33 searchPage.SearchField.Set("Atata");34 searchPage.SearchButton.Click();35 }36 }37}38using Atata;39using NUnit.Framework;40{41 {42 public void Test()43 {44 Go.To<GooglePage>();45 searchPage.SearchField.Set("Atata");46 searchPage.SearchButton.Click();47 }48 }49}50using Atata;51using NUnit.Framework;52{53 {54 public void Test()
AtataNavigator
Using AI Code Generation
1using Atata;2using NUnit.Framework;3{4 {5 public void SampleTest()6 {7 Go.To<HomePage>();8 Assert.That(AtataContext.Current.PageObject, Is.InstanceOf<HomePage>());9 Assert.That(AtataContext.Current.PageObject, Is.InstanceOf<HomePage>().And.Property("Title").EqualTo("Home"));10 AtataContext.Current.Go.To<AboutPage>();11 Assert.That(AtataContext.Current.PageObject, Is.InstanceOf<AboutPage>().And.Property("Title").EqualTo("About"));12 AtataContext.Current.Go.Back();13 Assert.That(AtataContext.Current.PageObject, Is.InstanceOf<HomePage>().And.Property("Title").EqualTo("Home"));14 AtataContext.Current.Go.Forward();15 Assert.That(AtataContext.Current.PageObject, Is.InstanceOf<AboutPage>().And.Property("Title").EqualTo("About"));16 }17 }18}19using Atata;20using NUnit.Framework;21{22 {23 public void SampleTest()24 {25 Go.To<HomePage>();26 Assert.That(AtataContext.Current.PageObject, Is.InstanceOf<HomePage>());27 Assert.That(AtataContext.Current.PageObject, Is.InstanceOf<HomePage>().And.Property("Title").EqualTo("Home"));28 AtataContext.Current.Go.To<AboutPage>();
AtataNavigator
Using AI Code Generation
1using Atata;2{3 {4 public static SampleApp Navigate => Go.To<SampleApp>();5 }6}7using Atata;8{9 {10 public SampleApp()11 {12 Title = "Atata Sample App";13 }14 public H1<UsersPage, _> Users { get; private set; }15 public H1<SignUpPage, _> SignUp { get; private set; }16 public H1<SignInPage, _> SignIn { get; private set; }17 }18}19using Atata;20{21 using _ = UsersPage;22 [Url("users")]23 {24 public H1<_> Heading { get; private set; }25 public Table<UserRow, _> Users { get; private set; }26 public ButtonDelegate<AddUserPage, _> AddUser { get; private set; }27 {28 public Text<_> Name { get; private set; }29 public Text<_> Email { get; private set; }30 public Text<_> Role { get; private set; }31 public ButtonDelegate<EditUserPage, _> Edit { get; private set; }32 public ButtonDelegate<_> Delete { get; private set; }33 }34 }35}36using Atata;37{38 using _ = AddUserPage;39 [Url("users/add")]40 {41 public H1<_> Heading { get; private set; }42 public TextInput<_> Name { get; private set; }43 public TextInput<_> Email { get; private set; }
AtataNavigator
Using AI Code Generation
1{2 public void TestMethod()3 {4 Build();5 Go.To<HomePage>();6 }7}8{9 public HomePage()10 {11 Url = "index.html";12 }13}14{15 [FindById("submit")]16 public ButtonDelegate<_> Submit { get; private set; }17}18{19 [FindById("submit")]20 public ButtonDelegate<_> Submit { get; private set; }21}22{23 [FindById("submit")]24 public ButtonDelegate<_> Submit { get; private set; }25}26{27 [FindById("submit")]28 public ButtonDelegate<_> Submit { get; private set; }29}30{31 [FindById("submit")]32 public ButtonDelegate<_> Submit { get; private set; }33}34{35 [FindById("submit")]36 public ButtonDelegate<_> Submit { get; private set; }37}38{39 [FindById("submit")]40 public ButtonDelegate<_> Submit { get; private set; }41}
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!