Ejemplo n.º 1
0
        private void SetUp(AtataContext context)
        {
            OnBuilding();

            if (context.BaseUrl != null)
            {
                context.Log.Trace($"Set: BaseUrl={context.BaseUrl}");
            }

            LogRetrySettings(context);

            if (BuildingContext.Culture != null)
            {
                ApplyCulture(context, BuildingContext.Culture);
            }

            context.DriverFactory = BuildingContext.DriverFactoryToUse;
            context.DriverAlias   = BuildingContext.DriverFactoryToUse.Alias;

            context.InitDriver();

            context.Log.Trace($"Set: Driver={context.Driver.GetType().Name}{BuildingContext.DriverFactoryToUse?.Alias?.ToFormattedString(" (alias={0})")}");

            OnBuilt();
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Builds the <see cref="AtataContext" /> instance and sets it to <see cref="AtataContext.Current" /> property.
        /// </summary>
        /// <returns>The created <see cref="AtataContext"/> instance.</returns>
        public AtataContext Build()
        {
            AtataContext.InitGlobalVariables();

            ValidateBuildingContextBeforeBuild();

            LogManager logManager = new LogManager();

            foreach (var logConsumerItem in BuildingContext.LogConsumers)
            {
                logManager.Use(logConsumerItem.Consumer, logConsumerItem.MinLevel, logConsumerItem.LogSectionFinish);
            }

            foreach (var screenshotConsumer in BuildingContext.ScreenshotConsumers)
            {
                logManager.Use(screenshotConsumer);
            }

            AtataContext context = new AtataContext
            {
                TestName = BuildingContext.TestNameFactory?.Invoke(),
                BaseUrl  = BuildingContext.BaseUrl,
                Log      = logManager,
                OnDriverCreatedActions    = BuildingContext.OnDriverCreatedActions?.ToList() ?? new List <Action <RemoteWebDriver> >(),
                CleanUpActions            = BuildingContext.CleanUpActions?.ToList() ?? new List <Action>(),
                BaseRetryTimeout          = BuildingContext.BaseRetryTimeout,
                BaseRetryInterval         = BuildingContext.BaseRetryInterval,
                ElementFindTimeout        = BuildingContext.ElementFindTimeout,
                ElementFindRetryInterval  = BuildingContext.ElementFindRetryInterval,
                WaitingTimeout            = BuildingContext.WaitingTimeout,
                WaitingRetryInterval      = BuildingContext.WaitingRetryInterval,
                VerificationTimeout       = BuildingContext.VerificationTimeout,
                VerificationRetryInterval = BuildingContext.VerificationRetryInterval,
                Culture = BuildingContext.Culture ?? CultureInfo.CurrentCulture,
                AssertionExceptionType          = BuildingContext.AssertionExceptionType,
                AggregateAssertionExceptionType = BuildingContext.AggregateAssertionExceptionType,
                AggregateAssertionStrategy      = BuildingContext.AggregateAssertionStrategy ?? new AtataAggregateAssertionStrategy(),
                WarningReportStrategy           = BuildingContext.WarningReportStrategy ?? new AtataWarningReportStrategy()
            };

            AtataContext.Current = context;

            OnBuilding(context);

            if (context.BaseUrl != null)
            {
                context.Log.Trace($"Set: BaseUrl={context.BaseUrl}");
            }

            LogRetrySettings(context);

            if (BuildingContext.Culture != null)
            {
                ApplyCulture(context, BuildingContext.Culture);
            }

            context.DriverFactory = BuildingContext.DriverFactoryToUse;
            context.DriverAlias   = BuildingContext.DriverFactoryToUse.Alias;

            context.InitDriver();

            context.Log.Trace($"Set: Driver={context.Driver.GetType().Name}{BuildingContext.DriverFactoryToUse?.Alias?.ToFormattedString(" (alias={0})")}");

            OnBuilt(context);

            return(context);
        }