Best Atata code snippet using Atata.AtataContextBuilder.UseChrome
AtataContextBuilder.cs
Source:AtataContextBuilder.cs  
...151        {152            switch (alias.ToLowerInvariant())153            {154                case DriverAliases.Chrome:155                    return UseChrome();156                case DriverAliases.Firefox:157                    return UseFirefox();158                case DriverAliases.InternetExplorer:159                    return UseInternetExplorer();160                case DriverAliases.Safari:161                    return UseSafari();162                case DriverAliases.Opera:163                    return UseOpera();164                case DriverAliases.Edge:165                    return UseEdge();166                default:167                    return null;168            }169        }170171        /// <summary>172        /// Sets the driver initialization stage.173        /// The default value is <see cref="AtataContextDriverInitializationStage.Build"/>.174        /// </summary>175        /// <param name="stage">The stage.</param>176        /// <returns>The <see cref="AtataContextBuilder"/> instance.</returns>177        public AtataContextBuilder UseDriverInitializationStage(AtataContextDriverInitializationStage stage)178        {179            BuildingContext.DriverInitializationStage = stage;180            return this;181        }182183        /// <summary>184        /// Creates and returns a new builder for <see cref="ChromeDriver"/>185        /// with default <see cref="DriverAliases.Chrome"/> alias.186        /// Sets this builder as a one to use for a driver creation.187        /// </summary>188        /// <returns>The <see cref="ChromeAtataContextBuilder"/> instance.</returns>189        public ChromeAtataContextBuilder UseChrome() =>190            UseDriver(new ChromeAtataContextBuilder(BuildingContext));191192        /// <summary>193        /// Creates and returns a new builder for <see cref="FirefoxDriver"/>194        /// with default <see cref="DriverAliases.Firefox"/> alias.195        /// Sets this builder as a one to use for a driver creation.196        /// </summary>197        /// <returns>The <see cref="FirefoxAtataContextBuilder"/> instance.</returns>198        public FirefoxAtataContextBuilder UseFirefox() =>199            UseDriver(new FirefoxAtataContextBuilder(BuildingContext));200201        /// <summary>202        /// Creates and returns a new builder for <see cref="InternetExplorerDriver"/>203        /// with default <see cref="DriverAliases.InternetExplorer"/> alias.204        /// Sets this builder as a one to use for a driver creation.205        /// </summary>206        /// <returns>The <see cref="InternetExplorerAtataContextBuilder"/> instance.</returns>207        public InternetExplorerAtataContextBuilder UseInternetExplorer() =>208            UseDriver(new InternetExplorerAtataContextBuilder(BuildingContext));209210        /// <summary>211        /// Creates and returns a new builder for <see cref="EdgeDriver"/>212        /// with default <see cref="DriverAliases.Edge"/> alias.213        /// Sets this builder as a one to use for a driver creation.214        /// </summary>215        /// <returns>The <see cref="EdgeAtataContextBuilder"/> instance.</returns>216        public EdgeAtataContextBuilder UseEdge() =>217            UseDriver(new EdgeAtataContextBuilder(BuildingContext));218219        /// <summary>220        /// Creates and returns a new builder for <see cref="OperaDriver"/>221        /// with default <see cref="DriverAliases.Opera"/> alias.222        /// Sets this builder as a one to use for a driver creation.223        /// </summary>224        /// <returns>The <see cref="OperaAtataContextBuilder"/> instance.</returns>225        public OperaAtataContextBuilder UseOpera() =>226            UseDriver(new OperaAtataContextBuilder(BuildingContext));227228        /// <summary>229        /// Creates and returns a new builder for <see cref="SafariDriver"/>230        /// with default <see cref="DriverAliases.Safari"/> alias.231        /// Sets this builder as a one to use for a driver creation.232        /// </summary>233        /// <returns>The <see cref="SafariAtataContextBuilder"/> instance.</returns>234        public SafariAtataContextBuilder UseSafari() =>235            UseDriver(new SafariAtataContextBuilder(BuildingContext));236237        /// <summary>238        /// Creates and returns a new builder for <see cref="RemoteWebDriver"/>239        /// with default <see cref="DriverAliases.Remote"/> alias.240        /// Sets this builder as a one to use for a driver creation.241        /// </summary>242        /// <returns>The <see cref="RemoteDriverAtataContextBuilder"/> instance.</returns>243        public RemoteDriverAtataContextBuilder UseRemoteDriver() =>244            UseDriver(new RemoteDriverAtataContextBuilder(BuildingContext));245246        /// <summary>247        /// Returns an existing or creates a new builder for <see cref="ChromeDriver"/> by the specified alias.248        /// </summary>249        /// <param name="alias">250        /// The driver alias.251        /// The default value is <see cref="DriverAliases.Chrome"/>.252        /// </param>253        /// <returns>The <see cref="ChromeAtataContextBuilder"/> instance.</returns>254        public ChromeAtataContextBuilder ConfigureChrome(string alias = DriverAliases.Chrome) =>255            ConfigureDriver(256                alias,257                () => new ChromeAtataContextBuilder(BuildingContext).WithAlias(alias));258259        /// <summary>260        /// Returns an existing or creates a new builder for <see cref="FirefoxDriver"/> by the specified alias.261        /// </summary>262        /// <param name="alias">263        /// The driver alias.264        /// The default value is <see cref="DriverAliases.Firefox"/>.265        /// </param>266        /// <returns>The <see cref="FirefoxAtataContextBuilder"/> instance.</returns>267        public FirefoxAtataContextBuilder ConfigureFirefox(string alias = DriverAliases.Firefox) =>268            ConfigureDriver(269                alias,270                () => new FirefoxAtataContextBuilder(BuildingContext).WithAlias(alias));271272        /// <summary>273        /// Returns an existing or creates a new builder for <see cref="InternetExplorerDriver"/> by the specified alias.274        /// </summary>275        /// <param name="alias">276        /// The driver alias.277        /// The default value is <see cref="DriverAliases.InternetExplorer"/>.278        /// </param>279        /// <returns>The <see cref="InternetExplorerAtataContextBuilder"/> instance.</returns>280        public InternetExplorerAtataContextBuilder ConfigureInternetExplorer(string alias = DriverAliases.InternetExplorer) =>281            ConfigureDriver(282                alias,283                () => new InternetExplorerAtataContextBuilder(BuildingContext).WithAlias(alias));284285        /// <summary>286        /// Returns an existing or creates a new builder for <see cref="EdgeDriver"/> by the specified alias.287        /// </summary>288        /// <param name="alias">289        /// The driver alias.290        /// The default value is <see cref="DriverAliases.Edge"/>.291        /// </param>292        /// <returns>The <see cref="EdgeAtataContextBuilder"/> instance.</returns>293        public EdgeAtataContextBuilder ConfigureEdge(string alias = DriverAliases.Edge) =>294            ConfigureDriver(295                alias,296                () => new EdgeAtataContextBuilder(BuildingContext).WithAlias(alias));297298        /// <summary>299        /// Returns an existing or creates a new builder for <see cref="OperaDriver"/> by the specified alias.300        /// </summary>301        /// <param name="alias">302        /// The driver alias.303        /// The default value is <see cref="DriverAliases.Opera"/>.304        /// </param>305        /// <returns>The <see cref="OperaAtataContextBuilder"/> instance.</returns>306        public OperaAtataContextBuilder ConfigureOpera(string alias = DriverAliases.Opera) =>307            ConfigureDriver(308                alias,309                () => new OperaAtataContextBuilder(BuildingContext).WithAlias(alias));310311        /// <summary>312        /// Returns an existing or creates a new builder for <see cref="SafariDriver"/> by the specified alias.313        /// </summary>314        /// <param name="alias">315        /// The driver alias.316        /// The default value is <see cref="DriverAliases.Safari"/>.317        /// </param>318        /// <returns>The <see cref="SafariAtataContextBuilder"/> instance.</returns>319        public SafariAtataContextBuilder ConfigureSafari(string alias = DriverAliases.Safari) =>320            ConfigureDriver(321                alias,322                () => new SafariAtataContextBuilder(BuildingContext).WithAlias(alias));323324        /// <summary>325        /// Returns an existing or creates a new builder for <see cref="RemoteWebDriver"/> by the specified alias.326        /// </summary>327        /// <param name="alias">328        /// The driver alias.329        /// The default value is <see cref="DriverAliases.Remote"/>.330        /// </param>331        /// <returns>The <see cref="RemoteDriverAtataContextBuilder"/> instance.</returns>332        public RemoteDriverAtataContextBuilder ConfigureRemoteDriver(string alias = DriverAliases.Remote) =>333            ConfigureDriver(334                alias,335                () => new RemoteDriverAtataContextBuilder(BuildingContext).WithAlias(alias));336337        [Obsolete("Use LogConsumers.Add(...) instead.")] // Obsolete since v2.0.0.338        public LogConsumerAtataContextBuilder<TLogConsumer> AddLogConsumer<TLogConsumer>()339            where TLogConsumer : ILogConsumer, new()340            =>341            LogConsumers.Add<TLogConsumer>();342343        [Obsolete("Use LogConsumers.Add(...) instead.")] // Obsolete since v2.0.0.344        public LogConsumerAtataContextBuilder<TLogConsumer> AddLogConsumer<TLogConsumer>(TLogConsumer consumer)345            where TLogConsumer : ILogConsumer346            =>347            LogConsumers.Add(consumer);348349        [Obsolete("Use LogConsumers.Add(...) instead.")] // Obsolete since v2.0.0.350        public LogConsumerAtataContextBuilder<ILogConsumer> AddLogConsumer(string typeNameOrAlias) =>351            LogConsumers.Add(typeNameOrAlias);352353        [Obsolete("Use LogConsumers.AddTrace() instead.")] // Obsolete since v2.0.0.354        public LogConsumerAtataContextBuilder<TraceLogConsumer> AddTraceLogging() =>355            LogConsumers.AddTrace();356357        [Obsolete("Use LogConsumers.AddDebug() instead.")] // Obsolete since v2.0.0.358        public LogConsumerAtataContextBuilder<DebugLogConsumer> AddDebugLogging() =>359            LogConsumers.AddDebug();360361        [Obsolete("Use LogConsumers.AddConsole() instead.")] // Obsolete since v2.0.0.362        public LogConsumerAtataContextBuilder<ConsoleLogConsumer> AddConsoleLogging() =>363            LogConsumers.AddConsole();364365        [Obsolete("Use LogConsumers.AddNUnitTestContext() instead.")] // Obsolete since v2.0.0.366        public LogConsumerAtataContextBuilder<NUnitTestContextLogConsumer> AddNUnitTestContextLogging() =>367            LogConsumers.AddNUnitTestContext();368369        [Obsolete("Use LogConsumers.AddNLog(...) instead.")] // Obsolete since v2.0.0.370        public LogConsumerAtataContextBuilder<NLogConsumer> AddNLogLogging(string loggerName = null) =>371            LogConsumers.AddNLog(loggerName);372373        [Obsolete("Use LogConsumers.AddNLogFile() instead.")] // Obsolete since v2.0.0.374        public LogConsumerAtataContextBuilder<NLogFileConsumer> AddNLogFileLogging() =>375            LogConsumers.AddNLogFile();376377        [Obsolete("Use LogConsumers.AddLog4Net(...) instead.")] // Obsolete since v2.0.0.378        public LogConsumerAtataContextBuilder<Log4NetConsumer> AddLog4NetLogging(string loggerName = null) =>379            LogConsumers.AddLog4Net(loggerName);380381        [Obsolete("Use LogConsumers.AddLog4Net(...) instead.")] // Obsolete since v2.0.0.382        public LogConsumerAtataContextBuilder<Log4NetConsumer> AddLog4NetLogging(string repositoryName, string loggerName = null) =>383            LogConsumers.AddLog4Net(repositoryName, loggerName);384385        [Obsolete("Use LogConsumers.AddLog4Net(...) instead.")] // Obsolete since v2.0.0.386        public LogConsumerAtataContextBuilder<Log4NetConsumer> AddLog4NetLogging(Assembly repositoryAssembly, string loggerName = null) =>387            LogConsumers.AddLog4Net(repositoryAssembly, loggerName);388389        /// <summary>390        /// Adds the variable.391        /// </summary>392        /// <param name="key">The variable key.</param>393        /// <param name="value">The variable value.</param>394        /// <returns>The <see cref="AtataContextBuilder"/> instance.</returns>395        public AtataContextBuilder AddVariable(string key, object value)396        {397            key.CheckNotNullOrWhitespace(nameof(key));398399            BuildingContext.Variables[key] = value;400401            return this;402        }403404        /// <summary>405        /// Adds the variables.406        /// </summary>407        /// <param name="variables">The variables to add.</param>408        /// <returns>The <see cref="AtataContextBuilder"/> instance.</returns>409        public AtataContextBuilder AddVariables(IDictionary<string, object> variables)410        {411            variables.CheckNotNull(nameof(variables));412413            foreach (var variable in variables)414                BuildingContext.Variables[variable.Key] = variable.Value;415416            return this;417        }418419        /// <summary>420        /// Adds the secret string to mask in log.421        /// </summary>422        /// <param name="value">The secret string value.</param>423        /// <param name="mask">The mask, which should replace the secret string.</param>424        /// <returns>The <see cref="AtataContextBuilder"/> instance.</returns>425        public AtataContextBuilder AddSecretStringToMaskInLog(string value, string mask = "{*****}")426        {427            value.CheckNotNullOrWhitespace(nameof(value));428            mask.CheckNotNullOrWhitespace(nameof(mask));429430            BuildingContext.SecretStringsToMaskInLog.Add(431                new SecretStringToMask(value, mask));432433            return this;434        }435436        [Obsolete("Use ScreenshotConsumers.Add<TScreenshotConsumer>() instead.")] // Obsolete since v2.0.0.437        public ScreenshotConsumerAtataContextBuilder<TScreenshotConsumer> AddScreenshotConsumer<TScreenshotConsumer>()438            where TScreenshotConsumer : IScreenshotConsumer, new()439            =>440            ScreenshotConsumers.Add<TScreenshotConsumer>();441442        [Obsolete("Use ScreenshotConsumers.Add(...) instead.")] // Obsolete since v2.0.0.443        public ScreenshotConsumerAtataContextBuilder<TScreenshotConsumer> AddScreenshotConsumer<TScreenshotConsumer>(TScreenshotConsumer consumer)444            where TScreenshotConsumer : IScreenshotConsumer445            =>446            ScreenshotConsumers.Add(consumer);447448        [Obsolete("Use ScreenshotConsumers.Add(...) instead.")] // Obsolete since v2.0.0.449        public ScreenshotConsumerAtataContextBuilder<IScreenshotConsumer> AddScreenshotConsumer(string typeNameOrAlias) =>450            ScreenshotConsumers.Add(typeNameOrAlias);451452        [Obsolete("Use ScreenshotConsumers.AddFile() instead.")] // Obsolete since v2.0.0.453        public ScreenshotConsumerAtataContextBuilder<FileScreenshotConsumer> AddScreenshotFileSaving() =>454            ScreenshotConsumers.AddFile();455456        /// <summary>457        /// Sets the factory method of the test name.458        /// </summary>459        /// <param name="testNameFactory">The factory method of the test name.</param>460        /// <returns>The <see cref="AtataContextBuilder"/> instance.</returns>461        public AtataContextBuilder UseTestName(Func<string> testNameFactory)462        {463            testNameFactory.CheckNotNull(nameof(testNameFactory));464465            BuildingContext.TestNameFactory = testNameFactory;466            return this;467        }468469        /// <summary>470        /// Sets the name of the test.471        /// </summary>472        /// <param name="testName">The name of the test.</param>473        /// <returns>The <see cref="AtataContextBuilder"/> instance.</returns>474        public AtataContextBuilder UseTestName(string testName)475        {476            BuildingContext.TestNameFactory = () => testName;477            return this;478        }479480        /// <summary>481        /// Sets the factory method of the test suite name.482        /// </summary>483        /// <param name="testSuiteNameFactory">The factory method of the test suite name.</param>484        /// <returns>The <see cref="AtataContextBuilder"/> instance.</returns>485        public AtataContextBuilder UseTestSuiteName(Func<string> testSuiteNameFactory)486        {487            testSuiteNameFactory.CheckNotNull(nameof(testSuiteNameFactory));488489            BuildingContext.TestSuiteNameFactory = testSuiteNameFactory;490            return this;491        }492493        /// <summary>494        /// Sets the name of the test suite (fixture/class).495        /// </summary>496        /// <param name="testSuiteName">The name of the test suite.</param>497        /// <returns>The <see cref="AtataContextBuilder"/> instance.</returns>498        public AtataContextBuilder UseTestSuiteName(string testSuiteName)499        {500            BuildingContext.TestSuiteNameFactory = () => testSuiteName;501            return this;502        }503504        /// <summary>505        /// Sets the factory method of the test suite (fixture/class) type.506        /// </summary>507        /// <param name="testSuiteTypeFactory">The factory method of the test suite type.</param>508        /// <returns>The <see cref="AtataContextBuilder"/> instance.</returns>509        public AtataContextBuilder UseTestSuiteType(Func<Type> testSuiteTypeFactory)510        {511            testSuiteTypeFactory.CheckNotNull(nameof(testSuiteTypeFactory));512513            BuildingContext.TestSuiteTypeFactory = testSuiteTypeFactory;514            return this;515        }516517        /// <summary>518        /// Sets the type of the test suite (fixture/class).519        /// </summary>520        /// <param name="testSuiteType">The type of the test suite.</param>521        /// <returns>The <see cref="AtataContextBuilder"/> instance.</returns>522        public AtataContextBuilder UseTestSuiteType(Type testSuiteType)523        {524            testSuiteType.CheckNotNull(nameof(testSuiteType));525526            BuildingContext.TestSuiteTypeFactory = () => testSuiteType;527            return this;528        }529530        /// <summary>531        /// Sets the UTC time zone.532        /// </summary>533        /// <returns>The <see cref="AtataContextBuilder"/> instance.</returns>534        public AtataContextBuilder UseUtcTimeZone() =>535            UseTimeZone(TimeZoneInfo.Utc);536537        /// <summary>538        /// Sets the time zone by identifier, which corresponds to the <see cref="TimeZoneInfo.Id"/> property.539        /// </summary>540        /// <param name="timeZoneId">The time zone identifier.</param>541        /// <returns>The <see cref="AtataContextBuilder"/> instance.</returns>542        public AtataContextBuilder UseTimeZone(string timeZoneId)543        {544            timeZoneId.CheckNotNullOrWhitespace(nameof(timeZoneId));545            TimeZoneInfo timeZone = TimeZoneInfo.FindSystemTimeZoneById(timeZoneId);546547            return UseTimeZone(timeZone);548        }549550        /// <summary>551        /// Sets the time zone.552        /// </summary>553        /// <param name="timeZone">The time zone.</param>554        /// <returns>The <see cref="AtataContextBuilder"/> instance.</returns>555        public AtataContextBuilder UseTimeZone(TimeZoneInfo timeZone)556        {557            timeZone.CheckNotNull(nameof(timeZone));558559            BuildingContext.TimeZone = timeZone;560            return this;561        }562563        /// <summary>564        /// Sets the base URL.565        /// </summary>566        /// <param name="baseUrl">The base URL.</param>567        /// <returns>The <see cref="AtataContextBuilder"/> instance.</returns>568        public AtataContextBuilder UseBaseUrl(string baseUrl)569        {570            if (baseUrl != null && !Uri.IsWellFormedUriString(baseUrl, UriKind.Absolute))571                throw new ArgumentException($"Invalid URL format \"{baseUrl}\".", nameof(baseUrl));572573            BuildingContext.BaseUrl = baseUrl;574            return this;575        }576577        /// <summary>578        /// Sets the base retry timeout.579        /// The default value is <c>5</c> seconds.580        /// </summary>581        /// <param name="timeout">The retry timeout.</param>582        /// <returns>The <see cref="AtataContextBuilder"/> instance.</returns>583        public AtataContextBuilder UseBaseRetryTimeout(TimeSpan timeout)584        {585            BuildingContext.BaseRetryTimeout = timeout;586            return this;587        }588589        /// <summary>590        /// Sets the base retry interval.591        /// The default value is <c>500</c> milliseconds.592        /// </summary>593        /// <param name="interval">The retry interval.</param>594        /// <returns>The <see cref="AtataContextBuilder"/> instance.</returns>595        public AtataContextBuilder UseBaseRetryInterval(TimeSpan interval)596        {597            BuildingContext.BaseRetryInterval = interval;598            return this;599        }600601        /// <summary>602        /// Sets the element find timeout.603        /// The default value is taken from <see cref="AtataBuildingContext.BaseRetryTimeout"/>, which is equal to <c>5</c> seconds by default.604        /// </summary>605        /// <param name="timeout">The retry timeout.</param>606        /// <returns>The <see cref="AtataContextBuilder"/> instance.</returns>607        public AtataContextBuilder UseElementFindTimeout(TimeSpan timeout)608        {609            BuildingContext.ElementFindTimeout = timeout;610            return this;611        }612613        /// <summary>614        /// Sets the element find retry interval.615        /// The default value is taken from <see cref="AtataBuildingContext.BaseRetryInterval"/>, which is equal to <c>500</c> milliseconds by default.616        /// </summary>617        /// <param name="interval">The retry interval.</param>618        /// <returns>The <see cref="AtataContextBuilder"/> instance.</returns>619        public AtataContextBuilder UseElementFindRetryInterval(TimeSpan interval)620        {621            BuildingContext.ElementFindRetryInterval = interval;622            return this;623        }624625        /// <summary>626        /// Sets the waiting timeout.627        /// The default value is taken from <see cref="AtataBuildingContext.BaseRetryTimeout"/>, which is equal to <c>5</c> seconds by default.628        /// </summary>629        /// <param name="timeout">The retry timeout.</param>630        /// <returns>The <see cref="AtataContextBuilder"/> instance.</returns>631        public AtataContextBuilder UseWaitingTimeout(TimeSpan timeout)632        {633            BuildingContext.WaitingTimeout = timeout;634            return this;635        }636637        /// <summary>638        /// Sets the waiting retry interval.639        /// The default value is taken from <see cref="AtataBuildingContext.BaseRetryInterval"/>, which is equal to <c>500</c> milliseconds by default.640        /// </summary>641        /// <param name="interval">The retry interval.</param>642        /// <returns>The <see cref="AtataContextBuilder"/> instance.</returns>643        public AtataContextBuilder UseWaitingRetryInterval(TimeSpan interval)644        {645            BuildingContext.WaitingRetryInterval = interval;646            return this;647        }648649        /// <summary>650        /// Sets the verification timeout.651        /// The default value is taken from <see cref="AtataBuildingContext.BaseRetryTimeout"/>, which is equal to <c>5</c> seconds by default.652        /// </summary>653        /// <param name="timeout">The retry timeout.</param>654        /// <returns>The <see cref="AtataContextBuilder"/> instance.</returns>655        public AtataContextBuilder UseVerificationTimeout(TimeSpan timeout)656        {657            BuildingContext.VerificationTimeout = timeout;658            return this;659        }660661        /// <summary>662        /// Sets the verification retry interval.663        /// The default value is taken from <see cref="AtataBuildingContext.BaseRetryInterval"/>, which is equal to <c>500</c> milliseconds by default.664        /// </summary>665        /// <param name="interval">The retry interval.</param>666        /// <returns>The <see cref="AtataContextBuilder"/> instance.</returns>667        public AtataContextBuilder UseVerificationRetryInterval(TimeSpan interval)668        {669            BuildingContext.VerificationRetryInterval = interval;670            return this;671        }672673        /// <summary>674        /// Sets the default control visibility.675        /// The default value is <see cref="Visibility.Any"/>.676        /// </summary>677        /// <param name="visibility">The visibility.</param>678        /// <returns>The <see cref="AtataContextBuilder"/> instance.</returns>679        public AtataContextBuilder UseDefaultControlVisibility(Visibility visibility)680        {681            BuildingContext.DefaultControlVisibility = visibility;682            return this;683        }684685        /// <summary>686        /// Sets the culture.687        /// The default value is <see cref="CultureInfo.CurrentCulture"/>.688        /// </summary>689        /// <param name="culture">The culture.</param>690        /// <returns>The <see cref="AtataContextBuilder"/> instance.</returns>691        public AtataContextBuilder UseCulture(CultureInfo culture)692        {693            BuildingContext.Culture = culture;694            return this;695        }696697        /// <summary>698        /// Sets the culture by the name.699        /// The default value is <see cref="CultureInfo.CurrentCulture"/>.700        /// </summary>701        /// <param name="cultureName">The name of the culture.</param>702        /// <returns>The <see cref="AtataContextBuilder"/> instance.</returns>703        public AtataContextBuilder UseCulture(string cultureName)704        {705            return UseCulture(CultureInfo.GetCultureInfo(cultureName));706        }707708        /// <summary>709        /// Sets the type of the assertion exception.710        /// The default value is a type of <see cref="AssertionException"/>.711        /// </summary>712        /// <typeparam name="TException">The type of the exception.</typeparam>713        /// <returns>The <see cref="AtataContextBuilder"/> instance.</returns>714        public AtataContextBuilder UseAssertionExceptionType<TException>()715            where TException : Exception716        {717            return UseAssertionExceptionType(typeof(TException));718        }719720        /// <summary>721        /// Sets the type of the assertion exception.722        /// The default value is a type of <see cref="AssertionException"/>.723        /// </summary>724        /// <param name="exceptionType">The type of the exception.</param>725        /// <returns>The <see cref="AtataContextBuilder"/> instance.</returns>726        public AtataContextBuilder UseAssertionExceptionType(Type exceptionType)727        {728            exceptionType.CheckIs<Exception>(nameof(exceptionType));729730            BuildingContext.AssertionExceptionType = exceptionType;731            return this;732        }733734        /// <summary>735        /// Sets the type of aggregate assertion exception.736        /// The default value is a type of <see cref="AggregateAssertionException"/>.737        /// The exception type should have public constructor with <c>IEnumerable<AssertionResult></c> argument.738        /// </summary>739        /// <typeparam name="TException">The type of the exception.</typeparam>740        /// <returns>The <see cref="AtataContextBuilder"/> instance.</returns>741        public AtataContextBuilder UseAggregateAssertionExceptionType<TException>()742            where TException : Exception743        {744            return UseAggregateAssertionExceptionType(typeof(TException));745        }746747        /// <summary>748        /// Sets the type of aggregate assertion exception.749        /// The default value is a type of <see cref="AggregateAssertionException"/>.750        /// The exception type should have public constructor with <c>IEnumerable<AssertionResult></c> argument.751        /// </summary>752        /// <param name="exceptionType">The type of the exception.</param>753        /// <returns>The <see cref="AtataContextBuilder"/> instance.</returns>754        public AtataContextBuilder UseAggregateAssertionExceptionType(Type exceptionType)755        {756            exceptionType.CheckIs<Exception>(nameof(exceptionType));757758            BuildingContext.AggregateAssertionExceptionType = exceptionType;759            return this;760        }761762        /// <summary>763        /// Sets the default assembly name pattern that is used to filter assemblies to find types in them.764        /// Modifies the <see cref="AtataBuildingContext.DefaultAssemblyNamePatternToFindTypes"/> property value of <see cref="BuildingContext"/>.765        /// </summary>766        /// <param name="pattern">The pattern.</param>767        /// <returns>The <see cref="AtataContextBuilder"/> instance.</returns>768        public AtataContextBuilder UseDefaultAssemblyNamePatternToFindTypes(string pattern)769        {770            pattern.CheckNotNullOrWhitespace(nameof(pattern));771772            BuildingContext.DefaultAssemblyNamePatternToFindTypes = pattern;773            return this;774        }775776        /// <summary>777        /// Sets the assembly name pattern that is used to filter assemblies to find component types in them.778        /// Modifies the <see cref="AtataBuildingContext.AssemblyNamePatternToFindComponentTypes"/> property value of <see cref="BuildingContext"/>.779        /// </summary>780        /// <param name="pattern">The pattern.</param>781        /// <returns>The <see cref="AtataContextBuilder"/> instance.</returns>782        public AtataContextBuilder UseAssemblyNamePatternToFindComponentTypes(string pattern)783        {784            pattern.CheckNotNullOrWhitespace(nameof(pattern));785786            BuildingContext.AssemblyNamePatternToFindComponentTypes = pattern;787            return this;788        }789790        /// <summary>791        /// Sets the assembly name pattern that is used to filter assemblies to find attribute types in them.792        /// Modifies the <see cref="AtataBuildingContext.AssemblyNamePatternToFindAttributeTypes"/> property value of <see cref="BuildingContext"/>.793        /// </summary>794        /// <param name="pattern">The pattern.</param>795        /// <returns>The <see cref="AtataContextBuilder"/> instance.</returns>796        public AtataContextBuilder UseAssemblyNamePatternToFindAttributeTypes(string pattern)797        {798            pattern.CheckNotNullOrWhitespace(nameof(pattern));799800            BuildingContext.AssemblyNamePatternToFindAttributeTypes = pattern;801            return this;802        }803804        /// <summary>805        /// Sets the assembly name pattern that is used to filter assemblies to find event types in them.806        /// Modifies the <see cref="AtataBuildingContext.AssemblyNamePatternToFindEventTypes"/> property value of <see cref="BuildingContext"/>.807        /// </summary>808        /// <param name="pattern">The pattern.</param>809        /// <returns>The <see cref="AtataContextBuilder"/> instance.</returns>810        public AtataContextBuilder UseAssemblyNamePatternToFindEventTypes(string pattern)811        {812            pattern.CheckNotNullOrWhitespace(nameof(pattern));813814            BuildingContext.AssemblyNamePatternToFindEventTypes = pattern;815            return this;816        }817818        /// <summary>819        /// Sets the assembly name pattern that is used to filter assemblies to find event handler types in them.820        /// Modifies the <see cref="AtataBuildingContext.AssemblyNamePatternToFindEventHandlerTypes"/> property value of <see cref="BuildingContext"/>.821        /// </summary>822        /// <param name="pattern">The pattern.</param>823        /// <returns>The <see cref="AtataContextBuilder"/> instance.</returns>824        public AtataContextBuilder UseAssemblyNamePatternToFindEventHandlerTypes(string pattern)825        {826            pattern.CheckNotNullOrWhitespace(nameof(pattern));827828            BuildingContext.AssemblyNamePatternToFindEventHandlerTypes = pattern;829            return this;830        }831832        /// <summary>833        /// Sets the path to the Artifacts directory.834        /// </summary>835        /// <param name="directoryPath">The directory path.</param>836        /// <returns>The <see cref="AtataContextBuilder"/> instance.</returns>837        public AtataContextBuilder UseArtifactsPath(string directoryPath)838        {839            directoryPath.CheckNotNullOrWhitespace(nameof(directoryPath));840841            return UseArtifactsPath(_ => directoryPath);842        }843844        /// <summary>845        /// Sets the builder of the path to the Artifacts directory.846        /// </summary>847        /// <param name="directoryPathBuilder">The directory path builder.</param>848        /// <returns>The <see cref="AtataContextBuilder"/> instance.</returns>849        public AtataContextBuilder UseArtifactsPath(Func<AtataContext, string> directoryPathBuilder)850        {851            directoryPathBuilder.CheckNotNull(nameof(directoryPathBuilder));852853            BuildingContext.ArtifactsPathBuilder = directoryPathBuilder;854            return this;855        }856857        /// <summary>858        /// Sets the default Artifacts path with optionally including <c>"{build-start:yyyyMMddTHHmmss}"</c> folder in the path.859        /// </summary>860        /// <param name="include">Whether to include the <c>"{build-start:yyyyMMddTHHmmss}"</c> folder in the path.</param>861        /// <returns>The <see cref="AtataContextBuilder"/> instance.</returns>862        public AtataContextBuilder UseDefaultArtifactsPathIncludingBuildStart(bool include) =>863            UseArtifactsPath(include864                ? AtataBuildingContext.DefaultArtifactsPath865                : AtataBuildingContext.DefaultArtifactsPathWithoutBuildStartFolder);866867        /// <summary>868        /// Defines that the name of the test should be taken from the NUnit test.869        /// </summary>870        /// <returns>The <see cref="AtataContextBuilder"/> instance.</returns>871        public AtataContextBuilder UseNUnitTestName()872        {873            return UseTestName(NUnitAdapter.GetCurrentTestName);874        }875876        /// <summary>877        /// Defines that the name of the test suite should be taken from the NUnit test fixture.878        /// </summary>879        /// <returns>The <see cref="AtataContextBuilder"/> instance.</returns>880        public AtataContextBuilder UseNUnitTestSuiteName()881        {882            return UseTestSuiteName(NUnitAdapter.GetCurrentTestFixtureName);883        }884885        /// <summary>886        /// Defines that the type of the test suite should be taken from the NUnit test fixture.887        /// </summary>888        /// <returns>The <see cref="AtataContextBuilder"/> instance.</returns>889        public AtataContextBuilder UseNUnitTestSuiteType()890        {891            return UseTestSuiteType(NUnitAdapter.GetCurrentTestFixtureType);892        }893894        /// <summary>895        /// Sets <see cref="NUnitAggregateAssertionStrategy"/> as the aggregate assertion strategy.896        /// The <see cref="NUnitAggregateAssertionStrategy"/> uses NUnit's <c>Assert.Multiple</c> method for aggregate assertion.897        /// </summary>898        /// <returns>The <see cref="AtataContextBuilder"/> instance.</returns>899        public AtataContextBuilder UseNUnitAggregateAssertionStrategy()900        {901            return UseAggregateAssertionStrategy(new NUnitAggregateAssertionStrategy());902        }903904        /// <summary>905        /// Sets the aggregate assertion strategy.906        /// </summary>907        /// <typeparam name="TAggregateAssertionStrategy">The type of the aggregate assertion strategy.</typeparam>908        /// <returns>The <see cref="AtataContextBuilder"/> instance.</returns>909        public AtataContextBuilder UseAggregateAssertionStrategy<TAggregateAssertionStrategy>()910            where TAggregateAssertionStrategy : IAggregateAssertionStrategy, new()911        {912            IAggregateAssertionStrategy strategy = Activator.CreateInstance<TAggregateAssertionStrategy>();913914            return UseAggregateAssertionStrategy(strategy);915        }916917        /// <summary>918        /// Sets the aggregate assertion strategy.919        /// </summary>920        /// <param name="strategy">The aggregate assertion strategy.</param>921        /// <returns>The <see cref="AtataContextBuilder"/> instance.</returns>922        public AtataContextBuilder UseAggregateAssertionStrategy(IAggregateAssertionStrategy strategy)923        {924            BuildingContext.AggregateAssertionStrategy = strategy;925926            return this;927        }928929        /// <summary>930        /// Sets <see cref="NUnitWarningReportStrategy"/> as the strategy for warning assertion reporting.931        /// </summary>932        /// <returns>The <see cref="AtataContextBuilder"/> instance.</returns>933        public AtataContextBuilder UseNUnitWarningReportStrategy()934        {935            return UseWarningReportStrategy(new NUnitWarningReportStrategy());936        }937938        /// <summary>939        /// Sets the strategy for warning assertion reporting.940        /// </summary>941        /// <param name="strategy">The warning report strategy.</param>942        /// <returns>The <see cref="AtataContextBuilder"/> instance.</returns>943        public AtataContextBuilder UseWarningReportStrategy(IWarningReportStrategy strategy)944        {945            BuildingContext.WarningReportStrategy = strategy;946947            return this;948        }949950        /// <summary>951        /// Defines that an error occurred during the NUnit test execution should be added to the log during the cleanup.952        /// </summary>953        /// <returns>The <see cref="AtataContextBuilder"/> instance.</returns>954        public AtataContextBuilder LogNUnitError() =>955            EventSubscriptions.Add(new LogNUnitErrorOnCleanUpEventHandler());956957        /// <summary>958        /// Defines that an error occurred during the NUnit test execution should be captured by a screenshot during the cleanup.959        /// </summary>960        /// <param name="title">The screenshot title.</param>961        /// <returns>The <see cref="AtataContextBuilder"/> instance.</returns>962        public AtataContextBuilder TakeScreenshotOnNUnitError(string title = "Failed") =>963            EventSubscriptions.Add(new TakeScreenshotOnNUnitErrorOnCleanUpEventHandler(title));964965        /// <summary>966        /// Defines that on <see cref="AtataContext"/> clean-up the files stored in Artifacts directory967        /// should be added to NUnit <c>TestContext</c>.968        /// </summary>969        /// <returns>The <see cref="AtataContextBuilder"/> instance.</returns>970        public AtataContextBuilder OnCleanUpAddArtifactsToNUnitTestContext() =>971            EventSubscriptions.Add(new AddArtifactsToNUnitTestContextOnCleanUpEventHandler());972973        /// <summary>974        /// Defines that on <see cref="AtataContext" /> clean-up the files stored in the directory975        /// specified by <paramref name="directoryPath"/> should be added to NUnit <c>TestContext</c>.976        /// Directory path supports template variables.977        /// </summary>978        /// <param name="directoryPath">The directory path.</param>979        /// <returns>The <see cref="AtataContextBuilder" /> instance.</returns>980        public AtataContextBuilder OnCleanUpAddDirectoryFilesToNUnitTestContext(string directoryPath)981        {982            directoryPath.CheckNotNull(nameof(directoryPath));983            return OnCleanUpAddDirectoryFilesToNUnitTestContext(_ => directoryPath);984        }985986        /// <inheritdoc cref="OnCleanUpAddDirectoryFilesToNUnitTestContext(Func{AtataContext, string})"/>987        public AtataContextBuilder OnCleanUpAddDirectoryFilesToNUnitTestContext(Func<string> directoryPathBuilder)988        {989            directoryPathBuilder.CheckNotNull(nameof(directoryPathBuilder));990            return OnCleanUpAddDirectoryFilesToNUnitTestContext(_ => directoryPathBuilder.Invoke());991        }992993        /// <summary>994        /// Defines that on <see cref="AtataContext" /> clean-up the files stored in the directory995        /// specified by <paramref name="directoryPathBuilder"/> should be added to NUnit <c>TestContext</c>.996        /// Directory path supports template variables.997        /// </summary>998        /// <param name="directoryPathBuilder">The directory path builder.</param>999        /// <returns>The <see cref="AtataContextBuilder" /> instance.</returns>1000        public AtataContextBuilder OnCleanUpAddDirectoryFilesToNUnitTestContext(Func<AtataContext, string> directoryPathBuilder)1001        {1002            directoryPathBuilder.CheckNotNull(nameof(directoryPathBuilder));1003            return EventSubscriptions.Add(1004                new AddDirectoryFilesToNUnitTestContextOnCleanUpEventHandler(directoryPathBuilder));1005        }10061007        /// <summary>1008        /// Sets the type of <c>NUnit.Framework.AssertionException</c> as the assertion exception type.1009        /// The default value is a type of <see cref="AssertionException"/>.1010        /// </summary>1011        /// <returns>The <see cref="AtataContextBuilder"/> instance.</returns>1012        public AtataContextBuilder UseNUnitAssertionExceptionType() =>1013            UseAssertionExceptionType(NUnitAdapter.AssertionExceptionType);10141015        /// <summary>1016        /// Enables all NUnit features for Atata.1017        /// Executes the following methods:1018        /// <list type="bullet">1019        /// <item><see cref="UseNUnitTestName"/>,</item>1020        /// <item><see cref="UseNUnitTestSuiteName"/>,</item>1021        /// <item><see cref="UseNUnitTestSuiteType"/>,</item>1022        /// <item><see cref="UseNUnitAssertionExceptionType"/>,</item>1023        /// <item><see cref="UseNUnitAggregateAssertionStrategy"/>,</item>1024        /// <item><see cref="UseNUnitWarningReportStrategy"/>,</item>1025        /// <item><see cref="LogConsumersAtataContextBuilder.AddNUnitTestContext"/>,</item>1026        /// <item><see cref="LogNUnitError"/>,</item>1027        /// <item><see cref="TakeScreenshotOnNUnitError(string)"/>,</item>1028        /// <item><see cref="OnCleanUpAddArtifactsToNUnitTestContext"/>.</item>1029        /// </list>1030        /// </summary>1031        /// <returns>The <see cref="AtataContextBuilder"/> instance.</returns>1032        public AtataContextBuilder UseAllNUnitFeatures() =>1033            UseNUnitTestName()1034                .UseNUnitTestSuiteName()1035                .UseNUnitTestSuiteType()1036                .UseNUnitAssertionExceptionType()1037                .UseNUnitAggregateAssertionStrategy()1038                .UseNUnitWarningReportStrategy()1039                .LogConsumers.AddNUnitTestContext()1040                .LogNUnitError()1041                .TakeScreenshotOnNUnitError()1042                .OnCleanUpAddArtifactsToNUnitTestContext();10431044        private DirectorySubject CreateArtifactsDirectorySubject(AtataContext context)1045        {1046            string pathTemplate = BuildingContext.ArtifactsPathBuilder.Invoke(context);10471048            string path = context.FillTemplateString(pathTemplate);10491050            return new DirectorySubject(path, "Artifacts");1051        }10521053        /// <summary>1054        /// Clears the <see cref="BuildingContext"/>.1055        /// </summary>1056        /// <returns>The <see cref="AtataContextBuilder"/> instance.</returns>1057        public AtataContextBuilder Clear()1058        {1059            BuildingContext = new AtataBuildingContext();1060            return this;1061        }10621063        /// <summary>1064        /// Builds the <see cref="AtataContext" /> instance and sets it to <see cref="AtataContext.Current" /> property.1065        /// </summary>1066        /// <returns>The created <see cref="AtataContext"/> instance.</returns>1067        public AtataContext Build()1068        {1069            ValidateBuildingContextBeforeBuild();10701071            AtataContext context = new AtataContext();1072            LogManager logManager = CreateLogManager(context);10731074            IObjectConverter objectConverter = new ObjectConverter1075            {1076                AssemblyNamePatternToFindTypes = BuildingContext.DefaultAssemblyNamePatternToFindTypes1077            };10781079            IObjectMapper objectMapper = new ObjectMapper(objectConverter);1080            IObjectCreator objectCreator = new ObjectCreator(objectConverter, objectMapper);10811082            context.TestName = BuildingContext.TestNameFactory?.Invoke();1083            context.TestSuiteName = BuildingContext.TestSuiteNameFactory?.Invoke();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();1103            context.ObjectConverter = objectConverter;1104            context.ObjectMapper = objectMapper;1105            context.ObjectCreator = objectCreator;1106            context.EventBus = new EventBus(context, BuildingContext.EventSubscriptions);11071108            if (context.TestSuiteName is null && context.TestSuiteType != null)1109                context.TestSuiteName = context.TestSuiteType.Name;11101111            context.DriverFactory = BuildingContext.DriverFactoryToUse1112                ?? BuildingContext.DriverFactories.LastOrDefault();1113            context.DriverAlias = context.DriverFactory?.Alias;1114            context.DriverInitializationStage = BuildingContext.DriverInitializationStage;11151116            context.InitDateTimeProperties();1117            context.InitMainVariables();1118            context.InitCustomVariables(BuildingContext.Variables);1119            context.Artifacts = CreateArtifactsDirectorySubject(context);1120            context.InitArtifactsVariable();11211122            AtataContext.Current = context;11231124            context.EventBus.Publish(new AtataContextPreInitEvent(context));11251126            context.LogTestStart();11271128            context.Log.ExecuteSection(1129                new LogSection("Set up AtataContext", LogLevel.Trace),1130                () => SetUp(context));11311132            context.PureExecutionStopwatch.Start();11331134            return context;1135        }11361137        private LogManager CreateLogManager(AtataContext context)1138        {1139            LogManager logManager = new LogManager(1140                new AtataContextLogEventInfoFactory(context));11411142            logManager.AddSecretStringsToMask(BuildingContext.SecretStringsToMaskInLog);11431144            foreach (var logConsumerItem in BuildingContext.LogConsumerConfigurations)1145                logManager.Use(logConsumerItem);11461147            foreach (var screenshotConsumer in BuildingContext.ScreenshotConsumers)1148                logManager.Use(screenshotConsumer);11491150            return logManager;1151        }11521153        private void SetUp(AtataContext context)1154        {1155            context.EventBus.Publish(new AtataContextInitStartedEvent(context));11561157            if (context.BaseUrl != null)1158                context.Log.Trace($"Set: BaseUrl={context.BaseUrl}");11591160            LogRetrySettings(context);11611162            if (BuildingContext.Culture != null)1163                ApplyCulture(context, BuildingContext.Culture);11641165            context.Log.Trace($"Set: Artifacts={context.Artifacts.FullName.Value}");11661167            if (context.DriverInitializationStage == AtataContextDriverInitializationStage.Build)1168                context.InitDriver();11691170            if (context.DriverInitializationStage != AtataContextDriverInitializationStage.None)1171            {1172                string driverTypeName = context.DriverInitializationStage == AtataContextDriverInitializationStage.OnDemand1173                    ? "{on demand}"1174                    : context.Driver.GetType().Name;11751176                context.Log.Trace($"Set: Driver={driverTypeName}{context.DriverFactory?.Alias?.ToFormattedString(" (alias={0})")}");1177            }11781179            context.EventBus.Publish(new AtataContextInitCompletedEvent(context));1180        }11811182        private static void LogRetrySettings(AtataContext context)1183        {1184            string messageFormat = "Set: {0}Timeout={1}; {0}RetryInterval={2}";11851186            context.Log.Trace(messageFormat, "ElementFind", context.ElementFindTimeout.ToShortIntervalString(), context.ElementFindRetryInterval.ToShortIntervalString());1187            context.Log.Trace(messageFormat, "Waiting", context.WaitingTimeout.ToShortIntervalString(), context.WaitingRetryInterval.ToShortIntervalString());1188            context.Log.Trace(messageFormat, "Verification", context.VerificationTimeout.ToShortIntervalString(), context.VerificationRetryInterval.ToShortIntervalString());1189        }11901191        private static void ApplyCulture(AtataContext context, CultureInfo culture)1192        {1193            Thread.CurrentThread.CurrentCulture = Thread.CurrentThread.CurrentUICulture = culture;11941195            if (AtataContext.ModeOfCurrent == AtataContextModeOfCurrent.Static)1196                CultureInfo.DefaultThreadCurrentCulture = CultureInfo.DefaultThreadCurrentUICulture = culture;11971198            context.Log.Trace($"Set: Culture={culture.Name}");1199        }12001201        private void ValidateBuildingContextBeforeBuild()1202        {1203            if (BuildingContext.DriverInitializationStage == AtataContextDriverInitializationStage.Build1204                && BuildingContext.DriverFactoryToUse == null1205                && BuildingContext.DriverFactories.Count == 0)1206            {1207                throw new InvalidOperationException(1208                    $"Cannot build {nameof(AtataContext)} as no driver is specified. " +1209                    $"Use one of \"Use*\" methods to specify the driver to use, e.g.:AtataContext.Configure().UseChrome().Build();");1210            }1211        }12121213        protected internal IObjectMapper CreateObjectMapper()1214        {1215            IObjectConverter objectConverter = new ObjectConverter1216            {1217                AssemblyNamePatternToFindTypes = BuildingContext.DefaultAssemblyNamePatternToFindTypes1218            };12191220            return new ObjectMapper(objectConverter);1221        }12221223        /// <summary>
...DriverTests.cs
Source:DriverTests.cs  
...45        [Test]46        public void Chrome_ThruGlobalConfiguration_AfterRuntimeConfiguration()47        {48            AtataContext.GlobalConfiguration.49                UseChrome().50                    WithCommandTimeout(TimeSpan.FromMinutes(2)).51                ApplyJsonConfig(@"Configs/Chrome.json");52            var context = ChromeAtataContextBuilderOverride.Context;53            using (context.UseNullDriver())54            {55                AtataContextBuilder builder = AtataContext.Configure();56                builder.BuildingContext.DriverFactoryToUse.Create();57            }58            VerifyChromeOptions(context.Options);59            VerifyChromeService(context.Service);60            context.CommandTimeout.Should().Be(TimeSpan.FromMinutes(1));61            VerifyChromeJsonConfig(JsonConfig.Global);62            JsonConfig.Current.Should().BeNull();63        }64        private static void VerifyChromeOptions(ChromeOptions options)65        {66            var capabilities = options.ToCapabilities();67            var browserCapabilities = (Dictionary<string, object>)capabilities.GetCapability(new ChromeOptions().CapabilityName);68            capabilities.GetCapability("goog:loggingPrefs").Should().BeEquivalentTo(new Dictionary<string, object>69            {70                ["browser"] = "INFO",71                ["driver"] = "WARNING"72            });73            browserCapabilities.Should().Contain(new Dictionary<string, object>74            {75                ["cap1"] = true,76                ["cap2"] = 5,77                ["cap3"] = "str"78            });79            capabilities.GetCapability("globalcap1").Should().Be(true);80            capabilities.GetCapability("globalcap2").Should().Be(5);81            capabilities.GetCapability("globalcap3").Should().Be("str");82            options.Proxy.Kind.Should().Be(ProxyKind.Manual);83            options.Proxy.HttpProxy.Should().Be("http");84            options.Proxy.FtpProxy.Should().Be("ftp");85            options.Arguments.Should().Equal("disable-extensions", "start-maximized");86            ((List<string>)browserCapabilities["excludeSwitches"]).Should().Equal("exc-arg");87            options.Extensions.Should().Equal("ZW5jLWV4dDE=", "ZW5jLWV4dDI=");88            ((List<string>)browserCapabilities["windowTypes"]).Should().Equal("win1", "win2");89            options.PerformanceLoggingPreferences.IsCollectingNetworkEvents.Should().BeFalse();90            options.PerformanceLoggingPreferences.IsCollectingPageEvents.Should().BeFalse();91            options.PerformanceLoggingPreferences.BufferUsageReportingInterval.Should().Be(TimeSpan.FromSeconds(70));92            options.PerformanceLoggingPreferences.TracingCategories.Should().Be("cat1,cat2");93            ((Dictionary<string, object>)browserCapabilities["prefs"]).Should().Equal(new Dictionary<string, object>94            {95                ["pref1"] = 7,96                ["pref2"] = false,97                ["pref3"] = "str"98            });99            ((Dictionary<string, object>)browserCapabilities["localState"]).Should().Equal(new Dictionary<string, object>100            {101                ["pref1"] = 2.7,102                ["pref2"] = true,103                ["pref3"] = string.Empty104            });105            ((Dictionary<string, object>)browserCapabilities["mobileEmulation"]).Should().Equal(new Dictionary<string, object>106            {107                ["deviceName"] = "emul"108            });109            browserCapabilities["androidPackage"].Should().Be("pack1");110            browserCapabilities["androidActivity"].Should().Be("act1");111            options.LeaveBrowserRunning.Should().BeTrue();112            options.MinidumpPath.Should().Be("mdp");113        }114        private static void VerifyChromeService(ChromeDriverService service)115        {116            service.Port.Should().Be(555);117            service.HostName.Should().Be("127.0.0.1");118            service.WhitelistedIPAddresses.Should().Be("5.5.5.5,7.7.7.7");119        }120        [Test]121        public void Chrome_ThruGlobalConfiguration_VerifyJsonConfig()122        {123            AtataContext.GlobalConfiguration.124                ApplyJsonConfig(@"Configs/Chrome.json");125            AtataContext.Configure()126                .UseChrome()127                .Build();128            VerifyChromeJsonConfig(JsonConfig.Current);129            VerifyChromeJsonConfig(JsonConfig.Global);130        }131        private static void VerifyChromeJsonConfig(JsonConfig config)132        {133            using (new AssertionScope())134            {135                config.Driver.Options.LoggingPreferences.Should().Equal(136                    new Dictionary<string, OpenQA.Selenium.LogLevel>137                    {138                        ["browser"] = OpenQA.Selenium.LogLevel.Info,139                        ["driver"] = OpenQA.Selenium.LogLevel.Warning140                    });...ChromeDriverJsonMapper.cs
Source:ChromeDriverJsonMapper.cs  
...3{4    public class ChromeDriverJsonMapper : ChromiumDriverJsonMapper<ChromeAtataContextBuilder, ChromeDriverService, ChromeOptions>5    {6        protected override ChromeAtataContextBuilder CreateDriverBuilder(AtataContextBuilder builder) =>7            builder.UseChrome();8        protected override void MapOptions(DriverOptionsJsonSection section, ChromeOptions options)9        {10            base.MapOptions(section, options);11            if (section.AdditionalBrowserOptions != null)12            {13                foreach (var item in section.AdditionalBrowserOptions.ExtraPropertiesMap)14                    options.AddAdditionalChromeOption(item.Key, FillTemplateVariables(item.Value));15            }16        }17    }18}...UseChrome
Using AI Code Generation
1{2    public void SetUp()3    {4        AtataContext.Configure()5            .UseChrome()6            .Build();7    }8    public void TearDown()9    {10        AtataContext.Current.CleanUp();11    }12}13{14    public void SetUp()15    {16        AtataContext.Configure()17            .UseChrome()18            .Build();19    }20    public void TearDown()21    {22        AtataContext.Current.CleanUp();23    }24}25{26    public void SetUp()27    {28        AtataContext.Configure()29            .UseChrome()30            .UseCulture("en-US")31            .Build();32    }33    public void TearDown()34    {35        AtataContext.Current.CleanUp();36    }37}38{39    public void SetUp()40    {41        AtataContext.Configure()42            .UseChrome()43            .UseCulture("en-US")44            .UseNUnitTestName()45            .Build();46    }47    public void TearDown()48    {49        AtataContext.Current.CleanUp();50    }51}52{53    public void SetUp()54    {55        AtataContext.Configure()56            .UseChrome()57            .UseCulture("en-US")58            .UseNUnitTestName()59            .UseAllNUnitFeatures()60            .Build();61    }UseChrome
Using AI Code Generation
1using Atata;2using NUnit.Framework;3{4    {5        public void SetUp()6        {7                Build();8        }9        public void TearDown()10        {11            AtataContext.Current?.CleanUp();12        }13    }14}15using Atata;16using NUnit.Framework;17{18    {19        public void SetUp()20        {21                Build();22        }23        public void TearDown()24        {25            AtataContext.Current?.CleanUp();26        }27    }28}29using Atata;30using NUnit.Framework;31{32    {33        public void SetUp()34        {35                Build();36        }37        public void TearDown()38        {39            AtataContext.Current?.CleanUp();40        }41    }42}43using Atata;44using NUnit.Framework;45{46    {47        public void SetUp()48        {49                Build();50        }51        public void TearDown()52        {53            AtataContext.Current?.CleanUp();54        }55    }56}UseChrome
Using AI Code Generation
1using Atata;2using NUnit.Framework;3{4    {5        public void SetUp()6        {7                Build();8        }9        public void TearDown()10        {11            AtataContext.Current.CleanUp();12        }13    }14}15using Atata;16using NUnit.Framework;17{18    {19        public void SetUp()20        {21                Build();22        }23        public void TearDown()24        {25            AtataContext.Current.CleanUp();26        }27    }28}29using Atata;30using NUnit.Framework;31{32    {33        public void SetUp()34        {35                Build();36        }37        public void TearDown()38        {39            AtataContext.Current.CleanUp();40        }41    }42}43using Atata;44using NUnit.Framework;45{46    {47        public void SetUp()48        {49                Build();50        }UseChrome
Using AI Code Generation
1{2    public void SetUp()3    {4        AtataContext.Configure()5            .UseChrome()6            .Build();7    }8}9{10    public void SetUp()11    {12        AtataContext.Configure()13            .UseChrome()14            .Build();15    }16}17{18    public void SetUp()19    {20        AtataContext.Configure()21            .UseChrome()22            .Build();23    }24}25{26    public void SetUp()27    {28        AtataContext.Configure()29            .UseChrome()30            .Build();31    }32}33{34    public void SetUp()35    {36        AtataContext.Configure()37            .UseChrome()38            .Build();39    }40}41{42    public void SetUp()43    {44        AtataContext.Configure()45            .UseChrome()46            .Build();47    }48}49{50    public void SetUp()51    {52        AtataContext.Configure()53            .UseChrome()UseChrome
Using AI Code Generation
1using System;2using Atata;3using NUnit.Framework;4{5    {6        public void SetUp()7        {8                Build();9        }10        public void _2()11        {12                Results.Should.HaveCountGreaterOrEqual(1);13        }14        public void TearDown()15        {16            AtataContext.Current?.CleanUp();17        }18    }19}20using System;21using Atata;22using NUnit.Framework;23{24    {25        public void SetUp()26        {27                Build();28        }29        public void _3()30        {31                Results.Should.HaveCountGreaterOrEqual(1);32        }33        public void TearDown()34        {35            AtataContext.Current?.CleanUp();36        }37    }38}39using System;40using Atata;41using NUnit.Framework;42{43    {44        public void SetUp()45        {46                Build();47        }48        public void _4()49        {50                Results.Should.HaveCountGreaterOrEqual(1);51        }52        public void TearDown()53        {54            AtataContext.Current?.CleanUp();55        }56    }57}58using System;59using Atata;60using NUnit.Framework;61{62    {63        public void SetUp()64        {65                Build();66        }UseChrome
Using AI Code Generation
1    Build();2    Build();3    Build();4    Build();5    Build();6    Build();7    Build();8    Build();9    Build();10    Build();11    Build();12    Build();13    Build();14    Build();15    Build();16    Build();17    Build();UseChrome
Using AI Code Generation
1{2    public void Test()3    {4            Build();5    }6}7{8    public void Test()9    {10            Header.Should.Contain("Atata Sample App");11    }12}13{14    public void Test()15    {16            Header.Should.Contain("Home Page");17    }18}19{20    public void Test()21    {22            Header.Should.Contain("Search");23    }24}25{26    public void Test()27    {UseChrome
Using AI Code Generation
1using Atata;2using NUnit.Framework;3{4    {5        public void TestMethod1()6        {7                Build();8        }9    }10}11    Build();UseChrome
Using AI Code Generation
1AtataContext.Configure().UseChrome().Build();2AtataContext.Configure().UseChrome().WithArguments("start-maximized").Build();3AtataContext.Configure().UseChrome().WithArguments("start-maximized", "disable-infobars").Build();4AtataContext.Configure().UseChrome().WithArguments("start-maximized", "disable-infobars").WithLocalDriverPath(@"C:\Selenium\Drivers").Build();5AtataContext.Configure().UseChrome().WithArguments("start-maximized", "disable-infobars").WithLocalDriverPath(@"C:\Selenium\Drivers").WithArguments("headless").Build();6AtataContext.Configure().UseChrome().WithArguments("start-maximized", "disable-infobars").WithLocalDriverPath(@"C:\Selenium\Drivers").WithArguments("headless").WithArguments("no-sandbox").Build();7AtataContext.Configure().UseChrome().WithArguments("start-maximized", "disable-infobars").WithLocalDriverPath(@"C:\Selenium\Drivers").WithArguments("headless").WithArguments("no-sandbox").WithArguments("disable-gpu").Build();8AtataContext.Configure().UseChrome().WithArguments("start-maximized", "disable-infobars").WithLocalDriverPath(@"C:\Selenium\Drivers").WithArguments("headless").WithArguments("no-sandbox").WithArguments("disable-gpu").WithArguments("disable-dev-shm-usage").Build();9AtataContext.Configure().UseChrome().WithArguments("start-maximized", "disable-infobars").WithLocalDriverPath(@"C:\Selenium\Drivers").WithArguments("headless").WithArguments("no-sandbox").WithArguments("disable-gpu").WithArguments("disable-dev-shm-usage").WithArguments("window-size=1920,1080").Build();10AtataContext.Configure().UseChrome().WithArguments("start-maximized", "disable-infobars").WithLocalDriverPath(@"C:\Selenium\Drivers").WithArguments("headless").WithArguments("no-sandbox").WithArguments("disable-gpu").WithArguments("disable-dev-shm-usage").WithArguments("window-size=1920,1080").WithArguments("disable-extensions").Build();11AtataContext.Configure().UseChrome().WithArguments("start-maximized", "disable-infobars").WithLocalDriverPath(@"C:\Selenium\DriversLearn 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!!
