コード例 #1
0
        public static TOwner Exist <TComponent, TOwner>(this IUIComponentVerificationProvider <TComponent, TOwner> should)
            where TComponent : UIComponent <TOwner>
            where TOwner : PageObject <TOwner>
        {
            should.CheckNotNull(nameof(should));

            AtataContext.Current.Log.Start(new VerificationLogSection(should.Component, $"{should.GetShouldText()} exist"));

            SearchOptions searchOptions = new SearchOptions
            {
                IsSafely      = false,
                Timeout       = should.Timeout ?? AtataContext.Current.VerificationTimeout,
                RetryInterval = should.RetryInterval ?? AtataContext.Current.VerificationRetryInterval
            };

            StaleSafely.Execute(
                options =>
            {
                if (should.IsNegation)
                {
                    should.Component.Missing(options);
                }
                else
                {
                    should.Component.Exists(options);
                }
            },
                searchOptions);

            AtataContext.Current.Log.EndSection();

            return(should.Owner);
        }
コード例 #2
0
        public static TOwner ExistSoft <TComponent, TOwner>(this IUIComponentVerificationProvider <TComponent, TOwner> should)
            where TComponent : UIComponent <TOwner>
            where TOwner : PageObject <TOwner>
        {
            should.CheckNotNull(nameof(should));

            string expectedMessage = "exist";

            AtataContext.Current.Log.Start(new VerificationLogSection(should.Component, $"{should.GetShouldText()} {expectedMessage}"));

            SearchOptions searchOptions = new SearchOptions
            {
                IsSafely      = false,
                Timeout       = should.Timeout ?? AtataContext.Current.VerificationTimeout,
                RetryInterval = should.RetryInterval ?? AtataContext.Current.VerificationRetryInterval
            };

            try
            {
                StaleSafely.Execute(
                    options =>
                {
                    if (should.IsNegation)
                    {
                        should.Component.Missing(options);
                    }
                    else
                    {
                        should.Component.Exists(options);
                    }
                },
                    searchOptions);
            }
            catch (Exception exception)
            {
                AtataContext.Current.Log.Info("NOT Exists!");
                StringBuilder messageBuilder = new StringBuilder().
                                               Append($"Invalid {should.Component.ComponentFullName} presence.").
                                               AppendLine().
                                               Append($"Expected: {should.GetShouldText()} {expectedMessage}");

                Exception ex = VerificationUtils.CreateAssertionException(messageBuilder.ToString(), exception);
                ExceptionResults.AddExecptionMessage(ex.Message);
            }
            AtataContext.Current.Log.Info("component styles: " + should.Component.Content);
            AtataContext.Current.Log.EndSection();

            return(should.Owner);
        }
コード例 #3
0
        public static TOwner Exist <TComponent, TOwner>(this IUIComponentVerificationProvider <TComponent, TOwner> should)
            where TComponent : UIComponent <TOwner>
            where TOwner : PageObject <TOwner>
        {
            should.CheckNotNull(nameof(should));

            string expectedMessage = "exist";

            AtataContext.Current.Log.ExecuteSection(
                new VerificationLogSection(should.VerificationKind, should.Component, $"{should.GetShouldText()} {expectedMessage}"),
                () =>
            {
                SearchOptions searchOptions = new SearchOptions
                {
                    IsSafely      = false,
                    Timeout       = should.Timeout ?? AtataContext.Current.VerificationTimeout,
                    RetryInterval = should.RetryInterval ?? AtataContext.Current.VerificationRetryInterval
                };

                try
                {
                    StaleSafely.Execute(
                        options =>
                    {
                        if (should.IsNegation)
                        {
                            should.Component.Missing(options);
                        }
                        else
                        {
                            should.Component.Exists(options);
                        }
                    },
                        searchOptions);
                }
                catch (Exception exception)
                {
                    string failureMessage = new StringBuilder().
                                            Append($"{should.Component.ComponentFullName} presence.").
                                            AppendLine().
                                            Append($"Expected: {should.GetShouldText()} {expectedMessage}").
                                            ToString();

                    should.ReportFailure(failureMessage, exception);
                }
            });

            return(should.Owner);
        }
コード例 #4
0
ファイル: UIComponent`1.cs プロジェクト: jetstreamin/atata
 protected virtual void OnWait(WaitUnit waitUnit)
 {
     StaleSafely.Execute(
         options =>
     {
         if (waitUnit.Method == WaitUnit.WaitMethod.Presence)
         {
             Exists(options);
         }
         else
         {
             Missing(options);
         }
     },
         waitUnit.SearchOptions);
 }
コード例 #5
0
        protected virtual void Wait <TOwner>(IUIComponent <TOwner> scopeComponent, WaitUnit waitUnit)
            where TOwner : PageObject <TOwner>
        {
            ScopeSource actualScopeSource = scopeSource ?? scopeComponent.ScopeSource;

            StaleSafely.Execute(
                options =>
            {
                ISearchContext scopeContext = actualScopeSource.GetScopeContext(scopeComponent, SearchOptions.Within(options.Timeout));

                By by = WaitBy.GetBy(Selector).With(options);

                if (waitUnit.Method == WaitUnit.WaitMethod.Presence)
                {
                    scopeContext.Exists(by);
                }
                else
                {
                    scopeContext.Missing(by);
                }
            },
                waitUnit.SearchOptions);
        }
        private static TOwner VerifyExistence <TComponent, TOwner>(
            IUIComponentVerificationProvider <TComponent, TOwner> should,
            string expectedMessage,
            string verificationStateName,
            Visibility?visibility = null)
            where TComponent : UIComponent <TOwner>
            where TOwner : PageObject <TOwner>
        {
            should.CheckNotNull(nameof(should));

            should.Component.Context.Log.ExecuteSection(
                new VerificationLogSection(should.VerificationKind, should.Component, $"{should.GetShouldText()} {expectedMessage}"),
                () =>
            {
                SearchOptions searchOptions = new SearchOptions
                {
                    IsSafely      = false,
                    Timeout       = should.Timeout ?? should.Component.Context.VerificationTimeout,
                    RetryInterval = should.RetryInterval ?? should.Component.Context.VerificationRetryInterval
                };

                if (visibility.HasValue)
                {
                    searchOptions.Visibility = visibility.Value;
                }

                try
                {
                    StaleSafely.Execute(
                        options =>
                    {
                        if (should.IsNegation)
                        {
                            should.Component.Missing(options);
                        }
                        else
                        {
                            should.Component.Exists(options);
                        }
                    },
                        searchOptions);
                }
                catch (Exception exception)
                {
                    var failureMessageBuilder = new StringBuilder().
                                                Append($"{should.Component.ComponentFullName} {verificationStateName}").
                                                AppendLine().
                                                Append($"Expected: {should.GetShouldText()} {expectedMessage}");

                    if (exception is NoSuchElementException || exception is NotMissingElementException)
                    {
                        failureMessageBuilder.AppendLine().Append($"  Actual: {exception.Message.ToLowerFirstLetter()}");
                        should.ReportFailure(failureMessageBuilder.ToString());
                    }
                    else
                    {
                        should.ReportFailure(failureMessageBuilder.ToString(), exception);
                    }
                }
            });

            return(should.Owner);
        }