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);
        }
        public static TOwner BeDisabled <TControl, TOwner>(this IUIComponentVerificationProvider <TControl, TOwner> should)
            where TControl : Control <TOwner>
            where TOwner : PageObject <TOwner>
        {
            should.CheckNotNull(nameof(should));

            return(should.Component.IsEnabled.Should.WithSettings(should).BeFalse());
        }
        public static TOwner BeHidden <TComponent, TOwner>(this IUIComponentVerificationProvider <TComponent, TOwner> should)
            where TComponent : UIComponent <TOwner>
            where TOwner : PageObject <TOwner>
        {
            should.CheckNotNull(nameof(should));

            return(should.Component.IsVisible.Should.WithSettings(should).BeFalse());
        }
        public static TOwner HaveClass <TComponent, TOwner>(this IUIComponentVerificationProvider <TComponent, TOwner> should, IEnumerable <string> classNames)
            where TComponent : UIComponent <TOwner>
            where TOwner : PageObject <TOwner>
        {
            should.CheckNotNull(nameof(should));

            return(should.Component.Attributes.Class.Should.WithSettings(should).Contain(classNames));
        }
        public static TOwner BeUnchecked <TControl, TOwner>(this IUIComponentVerificationProvider <TControl, TOwner> should)
            where TControl : Field <bool, TOwner>, ICheckable <TOwner>
            where TOwner : PageObject <TOwner>
        {
            should.CheckNotNull(nameof(should));

            return(should.Component.Should.WithSettings(should).BeFalse());
        }
        public static TOwner BeChecked <TControl, TOwner>(this IUIComponentVerificationProvider <TControl, TOwner> should)
            where TControl : Field <bool, TOwner>, ICheckable <TOwner>
            where TOwner : PageObject <TOwner>
        {
            should.CheckNotNull(nameof(should));

            var dataShould = should.Component.Should.ApplySettings(should);

            return(should.IsNegation ? dataShould.Not.BeTrue() : dataShould.BeTrue());
        }
        public static TOwner BeDisabled <TControl, TOwner>(this IUIComponentVerificationProvider <TControl, TOwner> should)
            where TControl : Control <TOwner>
            where TOwner : PageObject <TOwner>
        {
            should.CheckNotNull(nameof(should));

            var dataShould = should.Component.IsEnabled.Should.ApplySettings(should);

            return(should.IsNegation ? dataShould.Not.BeFalse() : dataShould.BeFalse());
        }
        public static TOwner BeHidden <TComponent, TOwner>(this IUIComponentVerificationProvider <TComponent, TOwner> should)
            where TComponent : UIComponent <TOwner>
            where TOwner : PageObject <TOwner>
        {
            should.CheckNotNull(nameof(should));

            var dataShould = should.Component.IsVisible.Should.ApplySettings(should);

            return(should.IsNegation ? dataShould.Not.BeFalse() : dataShould.BeFalse());
        }
Exemplo n.º 9
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);
        }
        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);
        }
 public static TOwner HaveClass <TComponent, TOwner>(this IUIComponentVerificationProvider <TComponent, TOwner> should, params string[] classNames)
     where TComponent : UIComponent <TOwner>
     where TOwner : PageObject <TOwner>
 {
     return(should.HaveClass(classNames.AsEnumerable()));
 }
 /// <summary>
 /// Verifies that the component exist.
 /// </summary>
 /// <typeparam name="TComponent">The type of the component.</typeparam>
 /// <typeparam name="TOwner">The type of the owner.</typeparam>
 /// <param name="should">The verification provider.</param>
 /// <returns>The owner instance.</returns>
 // TODO: Atata v2. Make obsolete. Use BePresent instead.
 public static TOwner Exist <TComponent, TOwner>(this IUIComponentVerificationProvider <TComponent, TOwner> should)
     where TComponent : UIComponent <TOwner>
     where TOwner : PageObject <TOwner>
 =>
 VerifyExistence(should, "exist", PresenceVerificationStateName);
        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);
        }
 /// <summary>
 /// Verifies that the component is hidden.
 /// </summary>
 /// <typeparam name="TComponent">The type of the component.</typeparam>
 /// <typeparam name="TOwner">The type of the owner.</typeparam>
 /// <param name="should">The verification provider.</param>
 /// <returns>The owner instance.</returns>
 public static TOwner BeHidden <TComponent, TOwner>(this IUIComponentVerificationProvider <TComponent, TOwner> should)
     where TComponent : UIComponent <TOwner>
     where TOwner : PageObject <TOwner>
 =>
 VerifyExistence(should, "be hidden", VisibilityVerificationStateName, Visibility.Hidden);