Exemplo n.º 1
0
        public IRoboElement TryFind(By locator)
        {
            if (locator == null)
            {
                throw new ArgumentNullException(
                          nameof(locator)
                          );
            }
            var pointer = new FixedWebPointer(this.Context, locator);

            pointer.Match();
            return(new RoboWebPointer(this.Robot, this.Context, pointer));
        }
Exemplo n.º 2
0
        public IRoboElement Find(By locator)
        {
            if (locator == null)
            {
                throw new ArgumentNullException(
                          nameof(locator)
                          );
            }
            var pointer = new FixedWebPointer(this.Context, locator);

            if (pointer.Match() == null)
            {
                throw new NotFoundException(
                          $"Element is not found: {locator}"
                          );
            }
            return(new RoboWebPointer(this.Robot, this.Context, pointer));
        }
Exemplo n.º 3
0
        public async Task <IRoboElement> TryFindAsync(By locator, TimeSpan timeout, CancellationToken token)
        {
            if (locator == null)
            {
                throw new ArgumentNullException(nameof(locator));
            }
            var pointer = new FixedWebPointer(this.Context, locator);
            var element = await this.Robot.Wait()
                          .UsingExceptionHandler(e => true)
                          .IgnoreConditionExceptions()
                          .NotThrowTimeoutException()
                          .WithTimeout(timeout)
                          .UntilAsync(() => {
                if (pointer.Match() != null)
                {
                    return((IRoboElement) new RoboWebPointer(this.Robot, this.Context, pointer));
                }
                return(null);
            });

            return(element ?? new RoboWebPointer(this.Robot, this.Context, pointer));
        }