示例#1
0
        public static By Within(this By by, TimeSpan timeout)
        {
            ExtendedBy extendedBy = new ExtendedBy(by);

            extendedBy.Options.Timeout = timeout;
            return(extendedBy);
        }
示例#2
0
        public static By AtOnce(this By by)
        {
            ExtendedBy extendedBy = new ExtendedBy(by);

            extendedBy.Options.Timeout = TimeSpan.Zero;
            return(extendedBy);
        }
示例#3
0
        public static By Safely(this By by, bool isSafely = true)
        {
            ExtendedBy extendedBy = new ExtendedBy(by);

            extendedBy.Options.IsSafely = isSafely;
            return(extendedBy);
        }
示例#4
0
        public static By Unsafely(this By by)
        {
            ExtendedBy extendedBy = new ExtendedBy(by);

            extendedBy.Options.IsSafely = false;
            return(extendedBy);
        }
示例#5
0
 public static By WithRetry(this By by, TimeSpan timeout, TimeSpan retryInterval)
 {
     ExtendedBy extendedBy = new ExtendedBy(by);
     extendedBy.Options.Timeout = timeout;
     extendedBy.Options.RetryInterval = retryInterval;
     return extendedBy;
 }
示例#6
0
 public static By SafelyAndImmediately(this By by, bool isSafely = true)
 {
     ExtendedBy extendedBy = new ExtendedBy(by);
     extendedBy.Options.IsSafely = isSafely;
     extendedBy.Options.Timeout = TimeSpan.Zero;
     return extendedBy;
 }
示例#7
0
        public static By With(this By by, SearchOptions options)
        {
            options = options ?? new SearchOptions();

            ExtendedBy extendedBy = new ExtendedBy(by);

            if (options.IsTimeoutSet)
            {
                extendedBy.Options.Timeout = options.Timeout;
            }

            if (options.IsRetryIntervalSet)
            {
                extendedBy.Options.RetryInterval = options.RetryInterval;
            }

            if (options.IsVisibilitySet)
            {
                extendedBy.Options.Visibility = options.Visibility;
            }

            if (options.IsSafelySet)
            {
                extendedBy.Options.IsSafely = options.IsSafely;
            }

            return(extendedBy);
        }
示例#8
0
        public static By With(this By by, Visibility visibility)
        {
            ExtendedBy extendedBy = new ExtendedBy(by);

            extendedBy.Options.Visibility = visibility;
            return(extendedBy);
        }
示例#9
0
        public static By Within(this By by, TimeSpan timeout, TimeSpan retryInterval)
        {
            ExtendedBy extendedBy = new ExtendedBy(by);

            extendedBy.Options.Timeout       = timeout;
            extendedBy.Options.RetryInterval = retryInterval;
            return(extendedBy);
        }
示例#10
0
        public static By SafelyAtOnce(this By by, bool isSafely = true)
        {
            ExtendedBy extendedBy = new ExtendedBy(by);

            extendedBy.Options.IsSafely = isSafely;
            extendedBy.Options.Timeout  = TimeSpan.Zero;
            return(extendedBy);
        }
示例#11
0
        public static By OfKind(this By by, string kind, string name = null)
        {
            ExtendedBy extendedBy = new ExtendedBy(by)
            {
                ElementKind = kind
            };

            return(name != null?extendedBy.Named(name) : extendedBy);
        }
        public ExtendedBy ApplySettingsFrom(ExtendedBy otherExtendedBy)
        {
            otherExtendedBy.CheckNotNull(nameof(otherExtendedBy));

            ElementName = otherExtendedBy.ElementName;
            ElementKind = otherExtendedBy.ElementKind;
            Options     = otherExtendedBy.Options.Clone();

            return(this);
        }
示例#13
0
        public static By With(this By by, SearchOptions options)
        {
            options = options ?? SearchOptions.Unsafely();

            ExtendedBy extendedBy = new ExtendedBy(by);
            extendedBy.Options.Timeout = options.Timeout;
            extendedBy.Options.RetryInterval = options.RetryInterval;
            extendedBy.Options.Visibility = options.Visibility;
            extendedBy.Options.IsSafely = options.IsSafely;
            return extendedBy;
        }
示例#14
0
        public static By Named(this By by, string name)
        {
            ExtendedBy extendedBy = new ExtendedBy(by);
            extendedBy.ElementName = name;

            if (name != null && extendedBy.ToString().Contains("{0}"))
            {
                return extendedBy.FormatWith(name);
            }

            return extendedBy;
        }
示例#15
0
        public static By Then(this By by, By nextBy)
        {
            ExtendedBy originalByAsExtended = by as ExtendedBy;

            By newByChain = TryResolveByChain(by, out ByChain byChain)
                ? new ByChain(byChain.Items.Concat(new[] { nextBy }))
                : new ByChain(originalByAsExtended?.By ?? by, nextBy);

            return(originalByAsExtended != null
                ? new ExtendedBy(newByChain).ApplySettingsFrom(originalByAsExtended)
                : newByChain);
        }
示例#16
0
        public static By Named(this By by, string name)
        {
            ExtendedBy extendedBy = new ExtendedBy(by)
            {
                ElementName = name
            };

            if (name != null && extendedBy.ToString().Contains("{0}"))
            {
                return(extendedBy.FormatWith(name));
            }

            return(extendedBy);
        }
        internal ExtendedBy(By by)
        {
            by.CheckNotNull(nameof(by));

            ExtendedBy byAsExtended = by as ExtendedBy;

            By          = byAsExtended?.By ?? by;
            Description = By.ToString();

            if (byAsExtended != null)
            {
                ApplySettingsFrom(byAsExtended);
            }
            else
            {
                Options = new SearchOptions();
            }
        }
示例#18
0
        public static By FormatWith(this By by, params object[] args)
        {
            string selector = string.Format(by.GetSelector(), args);
            By formattedBy = CreateBy(by.GetMethod(), selector);

            ExtendedBy extendedBy = new ExtendedBy(formattedBy);

            ExtendedBy originalByAsExtended = by as ExtendedBy;
            if (originalByAsExtended != null)
            {
                extendedBy.ElementName = originalByAsExtended.ElementName;
                extendedBy.ElementKind = originalByAsExtended.ElementKind;
                extendedBy.Options = originalByAsExtended.Options;
            }

            return extendedBy;
        }
示例#19
0
 public static By OfKind(this By by, string kind, string name = null)
 {
     ExtendedBy extendedBy = new ExtendedBy(by);
     extendedBy.ElementKind = kind;
     return name != null ? extendedBy.Named(name) : extendedBy;
 }
示例#20
0
 public static By Immediately(this By by)
 {
     ExtendedBy extendedBy = new ExtendedBy(by);
     extendedBy.Options.Timeout = TimeSpan.Zero;
     return extendedBy;
 }
示例#21
0
 public static By WithRetry(this By by, TimeSpan timeout)
 {
     ExtendedBy extendedBy = new ExtendedBy(by);
     extendedBy.Options.Timeout = timeout;
     return extendedBy;
 }
示例#22
0
 public static By OfAnyVisibility(this By by)
 {
     ExtendedBy extendedBy = new ExtendedBy(by);
     extendedBy.Options.Visibility = ElementVisibility.Any;
     return extendedBy;
 }
示例#23
0
 public static By Invisible(this By by)
 {
     ExtendedBy extendedBy = new ExtendedBy(by);
     extendedBy.Options.Visibility = ElementVisibility.Invisible;
     return extendedBy;
 }
示例#24
0
 public static By Safely(this By by, bool isSafely = true)
 {
     ExtendedBy extendedBy = new ExtendedBy(by);
     extendedBy.Options.IsSafely = isSafely;
     return extendedBy;
 }