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)); }
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)); }
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)); }