Best Atata code snippet using Atata.AtataBuildingContext.Clone
AtataContextBuilder.cs
Source:AtataContextBuilder.cs
...1084 context.TestSuiteType = BuildingContext.TestSuiteTypeFactory?.Invoke();1085 context.TimeZone = BuildingContext.TimeZone;1086 context.BaseUrl = BuildingContext.BaseUrl;1087 context.Log = logManager;1088 context.Attributes = BuildingContext.Attributes.Clone();1089 context.BaseRetryTimeout = BuildingContext.BaseRetryTimeout;1090 context.BaseRetryInterval = BuildingContext.BaseRetryInterval;1091 context.ElementFindTimeout = BuildingContext.ElementFindTimeout;1092 context.ElementFindRetryInterval = BuildingContext.ElementFindRetryInterval;1093 context.WaitingTimeout = BuildingContext.WaitingTimeout;1094 context.WaitingRetryInterval = BuildingContext.WaitingRetryInterval;1095 context.VerificationTimeout = BuildingContext.VerificationTimeout;1096 context.VerificationRetryInterval = BuildingContext.VerificationRetryInterval;1097 context.DefaultControlVisibility = BuildingContext.DefaultControlVisibility;1098 context.Culture = BuildingContext.Culture ?? CultureInfo.CurrentCulture;1099 context.AssertionExceptionType = BuildingContext.AssertionExceptionType;1100 context.AggregateAssertionExceptionType = BuildingContext.AggregateAssertionExceptionType;1101 context.AggregateAssertionStrategy = BuildingContext.AggregateAssertionStrategy ?? new AtataAggregateAssertionStrategy();1102 context.WarningReportStrategy = BuildingContext.WarningReportStrategy ?? new AtataWarningReportStrategy();
...
AtataContext.cs
Source:AtataContext.cs
...407 /// </summary>408 /// <returns>The created <see cref="AtataContextBuilder"/> instance.</returns>409 public static AtataContextBuilder Configure()410 {411 AtataBuildingContext buildingContext = GlobalConfiguration.BuildingContext.Clone();412 return new AtataContextBuilder(buildingContext);413 }414415 internal void InitDateTimeProperties()416 {417 StartedAtUtc = DateTime.UtcNow;418 StartedAt = TimeZoneInfo.ConvertTimeFromUtc(StartedAtUtc, TimeZone);419420 if (BuildStartUtc is null)421 {422 lock (s_buildStartSyncLock)423 {424 if (BuildStartUtc is null)425 {
...
AtataBuildingContext.cs
Source:AtataBuildingContext.cs
...8 /// <summary>9 /// Represents the building context for <see cref="AtataContext"/> creation.10 /// It is used by <see cref="AtataContextBuilder"/>.11 /// </summary>12 public class AtataBuildingContext : ICloneable13 {14 public const string DefaultArtifactsPath = "{basedir}/artifacts/{build-start:yyyyMMddTHHmmss}{test-suite-name-sanitized:/*}{test-name-sanitized:/*}";1516 public const string DefaultArtifactsPathWithoutBuildStartFolder = "{basedir}/artifacts{test-suite-name-sanitized:/*}{test-name-sanitized:/*}";1718 private TimeSpan? _elementFindTimeout;1920 private TimeSpan? _elementFindRetryInterval;2122 private TimeSpan? _waitingTimeout;2324 private TimeSpan? _waitingRetryInterval;2526 private TimeSpan? _verificationTimeout;2728 private TimeSpan? _verificationRetryInterval;2930 internal AtataBuildingContext()31 {32 }3334 /// <summary>35 /// Gets the driver factories.36 /// </summary>37 public List<IDriverFactory> DriverFactories { get; private set; } = new List<IDriverFactory>();3839 /// <summary>40 /// Gets the log consumer configurations.41 /// </summary>42 public List<LogConsumerConfiguration> LogConsumerConfigurations { get; private set; } = new List<LogConsumerConfiguration>();4344 /// <summary>45 /// Gets the variables dictionary.46 /// </summary>47 public IDictionary<string, object> Variables { get; private set; } = new Dictionary<string, object>();4849 /// <summary>50 /// Gets the list of secret strings to mask in log.51 /// </summary>52 public List<SecretStringToMask> SecretStringsToMaskInLog { get; private set; } = new List<SecretStringToMask>();5354 /// <summary>55 /// Gets the screenshot consumers.56 /// </summary>57 public List<IScreenshotConsumer> ScreenshotConsumers { get; private set; } = new List<IScreenshotConsumer>();5859 /// <summary>60 /// Gets the driver factory to use.61 /// </summary>62 public IDriverFactory DriverFactoryToUse { get; internal set; }6364 /// <summary>65 /// Gets or sets the driver initialization stage.66 /// The default value is <see cref="AtataContextDriverInitializationStage.Build"/>.67 /// </summary>68 public AtataContextDriverInitializationStage DriverInitializationStage { get; set; } = AtataContextDriverInitializationStage.Build;6970 /// <summary>71 /// Gets a value indicating whether it uses a local browser.72 /// Basically, determines whether <see cref="DriverFactoryToUse"/> is <see cref="IUsesLocalBrowser"/>.73 /// </summary>74 public bool UsesLocalBrowser =>75 DriverFactoryToUse is IUsesLocalBrowser;7677 /// <summary>78 /// Gets the name of the local browser to use or <see langword="null"/>.79 /// Returns <see cref="IUsesLocalBrowser.BrowserName"/> value if <see cref="DriverFactoryToUse"/> is <see cref="IUsesLocalBrowser"/>.80 /// </summary>81 public string LocalBrowserToUseName =>82 (DriverFactoryToUse as IUsesLocalBrowser)?.BrowserName;8384 /// <summary>85 /// Gets the names of local browsers that this instance uses.86 /// Distinctly returns <see cref="IUsesLocalBrowser.BrowserName"/> values of all <see cref="DriverFactories"/> that are <see cref="IUsesLocalBrowser"/>.87 /// </summary>88 public IEnumerable<string> ConfiguredLocalBrowserNames =>89 DriverFactories.OfType<IUsesLocalBrowser>().Select(x => x.BrowserName).Distinct();9091 /// <summary>92 /// Gets or sets the factory method of the test name.93 /// </summary>94 public Func<string> TestNameFactory { get; set; }9596 /// <summary>97 /// Gets or sets the factory method of the test suite name.98 /// </summary>99 public Func<string> TestSuiteNameFactory { get; set; }100101 /// <summary>102 /// Gets or sets the factory method of the test suite type.103 /// </summary>104 public Func<Type> TestSuiteTypeFactory { get; set; }105106 /// <summary>107 /// Gets or sets the time zone.108 /// The default value is <see cref="TimeZoneInfo.Local"/>.109 /// </summary>110 public TimeZoneInfo TimeZone { get; set; } = TimeZoneInfo.Local;111112 /// <summary>113 /// Gets or sets the base URL.114 /// </summary>115 public string BaseUrl { get; set; }116117 /// <summary>118 /// Gets the context of the attributes.119 /// </summary>120 public AtataAttributesContext Attributes { get; private set; } = new AtataAttributesContext();121122 /// <summary>123 /// Gets the list of event subscriptions.124 /// </summary>125 public List<EventSubscriptionItem> EventSubscriptions { get; private set; } = new List<EventSubscriptionItem>();126127 /// <summary>128 /// Gets or sets the default assembly name pattern that is used to filter assemblies to find types in them.129 /// The default value is <c>@"^(?!System($|\..+$)|mscorlib$|netstandard$|Microsoft\..+)"</c>, which filters non-system assemblies.130 /// </summary>131 public string DefaultAssemblyNamePatternToFindTypes { get; set; } = @"^(?!System($|\..+)|mscorlib$|netstandard$|Microsoft\..+)";132133 /// <summary>134 /// Gets or sets the assembly name pattern that is used to filter assemblies to find component types in them.135 /// The default value is <see langword="null"/>, which means to use <see cref="DefaultAssemblyNamePatternToFindTypes"/>.136 /// </summary>137 public string AssemblyNamePatternToFindComponentTypes { get; set; }138139 /// <summary>140 /// Gets or sets the assembly name pattern that is used to filter assemblies to find attribute types in them.141 /// The default value is <see langword="null"/>, which means to use <see cref="DefaultAssemblyNamePatternToFindTypes"/>.142 /// </summary>143 public string AssemblyNamePatternToFindAttributeTypes { get; set; }144145 /// <summary>146 /// Gets or sets the assembly name pattern that is used to filter assemblies to find event types in them.147 /// The default value is <see langword="null"/>, which means to use <see cref="DefaultAssemblyNamePatternToFindTypes"/>.148 /// </summary>149 public string AssemblyNamePatternToFindEventTypes { get; set; }150151 /// <summary>152 /// Gets or sets the assembly name pattern that is used to filter assemblies to find event handler types in them.153 /// The default value is <see langword="null"/>, which means to use <see cref="DefaultAssemblyNamePatternToFindTypes"/>.154 /// </summary>155 public string AssemblyNamePatternToFindEventHandlerTypes { get; set; }156157 /// <summary>158 /// Gets or sets the Artifacts directory path builder.159 /// The default builder returns <c>"{basedir}/artifacts/{build-start:yyyyMMddTHHmmss}{test-suite-name-sanitized:/*}{test-name-sanitized:/*}"</c>.160 /// </summary>161 public Func<AtataContext, string> ArtifactsPathBuilder { get; set; } = _ => DefaultArtifactsPath;162163 /// <summary>164 /// Gets the base retry timeout.165 /// The default value is <c>5</c> seconds.166 /// </summary>167 public TimeSpan BaseRetryTimeout { get; internal set; } = AtataContext.DefaultRetryTimeout;168169 /// <summary>170 /// Gets the base retry interval.171 /// The default value is <c>500</c> milliseconds.172 /// </summary>173 public TimeSpan BaseRetryInterval { get; internal set; } = AtataContext.DefaultRetryInterval;174175 /// <summary>176 /// Gets the element find timeout.177 /// The default value is taken from <see cref="BaseRetryTimeout"/>, which is equal to <c>5</c> seconds by default.178 /// </summary>179 public TimeSpan ElementFindTimeout180 {181 get => _elementFindTimeout ?? BaseRetryTimeout;182 internal set => _elementFindTimeout = value;183 }184185 /// <summary>186 /// Gets the element find retry interval.187 /// The default value is taken from <see cref="BaseRetryInterval"/>, which is equal to <c>500</c> milliseconds by default.188 /// </summary>189 public TimeSpan ElementFindRetryInterval190 {191 get => _elementFindRetryInterval ?? BaseRetryInterval;192 internal set => _elementFindRetryInterval = value;193 }194195 /// <summary>196 /// Gets the waiting timeout.197 /// The default value is taken from <see cref="BaseRetryTimeout"/>, which is equal to 5 seconds by default.198 /// </summary>199 public TimeSpan WaitingTimeout200 {201 get => _waitingTimeout ?? BaseRetryTimeout;202 internal set => _waitingTimeout = value;203 }204205 /// <summary>206 /// Gets the waiting retry interval.207 /// The default value is taken from <see cref="BaseRetryInterval"/>, which is equal to <c>500</c> milliseconds by default.208 /// </summary>209 public TimeSpan WaitingRetryInterval210 {211 get => _waitingRetryInterval ?? BaseRetryInterval;212 internal set => _waitingRetryInterval = value;213 }214215 /// <summary>216 /// Gets the verification timeout.217 /// The default value is taken from <see cref="BaseRetryTimeout"/>, which is equal to <c>5</c> seconds by default.218 /// </summary>219 public TimeSpan VerificationTimeout220 {221 get => _verificationTimeout ?? BaseRetryTimeout;222 internal set => _verificationTimeout = value;223 }224225 /// <summary>226 /// Gets the verification retry interval.227 /// The default value is taken from <see cref="BaseRetryInterval"/>, which is equal to <c>500</c> milliseconds by default.228 /// </summary>229 public TimeSpan VerificationRetryInterval230 {231 get => _verificationRetryInterval ?? BaseRetryInterval;232 internal set => _verificationRetryInterval = value;233 }234235 /// <summary>236 /// Gets or sets the default control visibility.237 /// The default value is <see cref="Visibility.Any"/>.238 /// </summary>239 public Visibility DefaultControlVisibility { get; set; }240241 /// <summary>242 /// Gets or sets the culture.243 /// </summary>244 public CultureInfo Culture { get; set; }245246 /// <summary>247 /// Gets or sets the type of the assertion exception.248 /// The default value is a type of <see cref="AssertionException"/>.249 /// </summary>250 public Type AssertionExceptionType { get; set; } = typeof(AssertionException);251252 /// <summary>253 /// Gets or sets the type of the aggregate assertion exception.254 /// The default value is a type of <see cref="AggregateAssertionException"/>.255 /// The exception type should have public constructor with <c>IEnumerable<AssertionResult></c> argument.256 /// </summary>257 public Type AggregateAssertionExceptionType { get; set; } = typeof(AggregateAssertionException);258259 /// <summary>260 /// Gets or sets the aggregate assertion strategy.261 /// The default value is an instance of <see cref="AtataAggregateAssertionStrategy"/>.262 /// </summary>263 public IAggregateAssertionStrategy AggregateAssertionStrategy { get; set; } = new AtataAggregateAssertionStrategy();264265 /// <summary>266 /// Gets or sets the strategy for warning assertion reporting.267 /// The default value is an instance of <see cref="AtataWarningReportStrategy"/>.268 /// </summary>269 public IWarningReportStrategy WarningReportStrategy { get; set; } = new AtataWarningReportStrategy();270271 /// <summary>272 /// Gets the driver factory by the specified alias.273 /// </summary>274 /// <param name="alias">The alias of the driver factory.</param>275 /// <returns>The driver factory or <see langword="null"/>.</returns>276 public IDriverFactory GetDriverFactory(string alias)277 {278 alias.CheckNotNullOrWhitespace(nameof(alias));279280 return DriverFactories.LastOrDefault(x => alias.Equals(x.Alias, StringComparison.OrdinalIgnoreCase));281 }282283 /// <inheritdoc cref="Clone"/>284 object ICloneable.Clone() =>285 Clone();286287 /// <summary>288 /// Creates a copy of the current instance.289 /// </summary>290 /// <returns>The copied <see cref="AtataBuildingContext"/> instance.</returns>291 public AtataBuildingContext Clone()292 {293 AtataBuildingContext copy = (AtataBuildingContext)MemberwiseClone();294295 copy.DriverFactories = DriverFactories.ToList();296297 copy.LogConsumerConfigurations = LogConsumerConfigurations298 .Select(x => x.Consumer is ICloneable ? x.Clone() : x)299 .ToList();300301 copy.ScreenshotConsumers = ScreenshotConsumers302 .Select(x => x is ICloneable cloneableConsumer ? (IScreenshotConsumer)cloneableConsumer.Clone() : x)303 .ToList();304305 copy.Attributes = Attributes.Clone();306 copy.EventSubscriptions = EventSubscriptions.ToList();307 copy.Variables = new Dictionary<string, object>(Variables);308 copy.SecretStringsToMaskInLog = SecretStringsToMaskInLog.ToList();309310 return copy;311 }312 }313}
...
Clone
Using AI Code Generation
1using System;2using System.Collections.Generic;3using System.Linq;4using System.Text;5using System.Threading.Tasks;6using Atata;7using NUnit.Framework;8{9 {10 public void Test()11 {12 var context = AtataContext.Configure().Build();13 var newContext = context.Clone();14 newContext.Log.Info("New context has been created.");15 newContext.CleanUp();16 }17 }18}19The CleanUp()
Clone
Using AI Code Generation
1using System;2using System.Collections.Generic;3using System.Linq;4using System.Text;5using System.Threading.Tasks;6using Atata;7{8 {9 public _2 Clone()10 {11 return (AtataBuildingContext)base.Clone();12 }13 }14}15using System;16using System.Collections.Generic;17using System.Linq;18using System.Text;19using System.Threading.Tasks;20using Atata;21{22 {23 public _3 Clone()24 {25 return (AtataContext)base.Clone();26 }27 }28}29using System;30using System.Collections.Generic;31using System.Linq;32using System.Text;33using System.Threading.Tasks;34using Atata;35{36 {37 public _4 Clone()38 {39 return (AtataContextBuilder)base.Clone();40 }41 }42}43using System;44using System.Collections.Generic;45using System.Linq;46using System.Text;47using System.Threading.Tasks;48using Atata;49{50 {51 public _5 Clone()52 {53 return (AtataContextBuilder<_5>)base.Clone();54 }55 }56}57using System;58using System.Collections.Generic;59using System.Linq;60using System.Threading.Tasks;61using Atata;62{63 {64 public _6 Clone()65 {66 return (AtataContextBuilder<_6>)base.Clone();67 }68 }69}70using System;71using System.Collections.Generic;72using System.Linq;73using System.Threading.Tasks;74using Atata;75{
Clone
Using AI Code Generation
1using System;2using Atata;3{4 {5 static void Main(string[] args)6 {7 var context = new AtataBuildingContext();8 var context1 = context.Clone();9 Console.WriteLine("Context 1: " + context1);10 var context2 = context1.Clone();11 Console.WriteLine("Context 2: " + context2);12 Console.ReadKey();13 }14 }15}
Clone
Using AI Code Generation
1using Atata;2{3 {4 public _2()5 {6 AtataContext.Configure()7 .UseChrome()8 .UseCulture("en-US")9 .UseAllNUnitFeatures()10 .LogNUnitError()11 .AddNUnitTestContextLogging()12 .Build();13 }14 public void Clone()15 {16 Go.To<HomePage>()17 .SignIn.ClickAndGo()18 .Email.Set("
Clone
Using AI Code Generation
1using Atata;2using NUnit.Framework;3{4 {5 public void Clone()6 {7 .Clone()8 .UseChrome()9 .Build()10 .GoTo<NUnitSampleAppPage>()11 .Header.Should.Exist();12 }13 }14}15using Atata;16using NUnit.Framework;17{18 {19 public void Clone()20 {21 .Clone()22 .UseChrome()23 .Build()24 .GoTo<NUnitSampleAppPage>()25 .Header.Should.Exist();26 }27 }28}29using Atata;30using NUnit.Framework;31{32 {33 public void Clone()34 {35 .Clone()36 .UseChrome()37 .Build()38 .GoTo<NUnitSampleAppPage>()39 .Header.Should.Exist();40 }41 }42}43using Atata;44using NUnit.Framework;45{46 {47 public void Clone()48 {49 .Clone()50 .UseChrome()51 .Build()52 .GoTo<NUnitSampleAppPage>()53 .Header.Should.Exist();54 }55 }56}57using Atata;58using NUnit.Framework;59{60 {61 public void Clone()62 {63 .Clone()64 .UseChrome()65 .Build()66 .GoTo<NUnitSampleAppPage>()67 .Header.Should.Exist();68 }69 }70}71using Atata;72using NUnit.Framework;
Clone
Using AI Code Generation
1using Atata;2using NUnit.Framework;3using System;4{5 {6 public void Clone()7 {8 Build();9 var clonedContext = context.Clone();10 clonedContext.Log.Info("This is a cloned context");11 clonedContext.Log.Info("The context is cloned from the context with build name '{0}'", context.BuildName);12 clonedContext.Log.Info("The context is cloned from the context with build start time '{0}'", context.BuildStartTime);13 clonedContext.Log.Info("The context is cloned from the context with build end time '{0}'", context.BuildEndTime);14 clonedContext.Log.Info("The context is cloned from the context with build duration '{0}'", context.BuildDuration);15 clonedContext.Log.Info("The context is cloned from the context with build status '{0}'", context.BuildStatus);16 clonedContext.Log.Info("The context is cloned from the context with build error '{0}'", context.BuildError);17 clonedContext.Log.Info("The context is cloned from the context with build error stack trace '{0}'", context.BuildErrorStackTrace);18 clonedContext.Log.Info("The context is cloned from the context with build log '{0}'", context.BuildLog);19 clonedContext.Log.Info("The context is cloned from the context with build log file path '{0}'", context.BuildLogFile);20 clonedContext.Log.Info("The context is cloned from the context with build log file name '{0}'", context.BuildLogFileName);21 clonedContext.Log.Info("The context is cloned from the context with build log file name without extension '{0}'", context.BuildLogFileNameWithoutExtension);22 clonedContext.Log.Info("The context is cloned from the context with build log file extension '{0}'", context.BuildLogFileExtension);23 clonedContext.Log.Info("The context is cloned from the context with build log file directory '{0}'", context.BuildLogFileDirectory);24 clonedContext.Log.Info("The context is cloned from the context with build log file full path '{0}'", context.BuildLogFileFullPath);25 clonedContext.Log.Info("The context is cloned from the context with build log file size '{0}'", context.BuildLogFileSize);26 clonedContext.Log.Info("The context is cloned from the context with build log file creation time '{0}'", context.BuildLogFileCreationTime);27 clonedContext.Log.Info("The context is cloned from the context with build log file last write time '{0
Clone
Using AI Code Generation
1using Atata;2using NUnit.Framework;3{4 {5 public void Clone()6 {7 Go.To<Page4>();8 }9 }10 {11 }12 {13 }14 {15 }16 {17 }18}19using Atata;20using NUnit.Framework;21{22 {23 public void Clone()24 {25 Go.To<Page4>();26 }27 }28 {29 }30 {31 }32 {33 }34 {35 }36}37using Atata;38using NUnit.Framework;39{40 {41 public void Clone()42 {43 Go.To<Page4>();44 }45 }46 {47 }48 {49 }50 {51 }52 {53 }54}55using Atata;56using NUnit.Framework;57{58 {59 public void Clone()
Clone
Using AI Code Generation
1using Atata;2using NUnit.Framework;3{4 {5 public void Test()6 {7 var context = AtataContext.Configure()8 .UseChrome()9 .UseCulture("en-US")10 .Build();11 context.Log.Info("Start test");12 context.Go.To<GooglePage>().SearchFor("Atata");13 var searchResultPage = context.Clone().Go.To<GoogleSearchResultPage>();14 searchResultPage.Should.HaveSearchResults();15 }16 }17}18AtataContext: UseCulture("en-US")19AtataContext: UseChrome()20AtataContext: UseCulture("en-US")21AtataContext: UseChrome()
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!!