internal override object getTarget(IInvocation ignored) { if (cached != null) { return(cached); } ITimeouts timeOuts = WebDriverUnpackUtility.UnpackWebdriver(locator.SearchContext).Manage().Timeouts(); try { timeOuts.ImplicitWait = zeroTimeSpan; waitingForElementList.Timeout = waitingTimeSpan.WaitingDuration; var result = waitingForElementList.Until(ReturnWaitingFunction(locator, bys))[0]; if (shouldCache && cached == null) { cached = result; } return(result); } catch (WebDriverTimeoutException e) { string bysString = ""; foreach (var by in bys) { bysString = bysString + by.ToString() + " "; } throw new NoSuchElementException("Couldn't locate an element by these strategies: " + bysString, e); } finally { timeOuts.ImplicitWait = waitingTimeSpan.WaitingDuration; } }
internal override object getTarget(IInvocation invocation) { if (cached != null) { return(cached); } Type genericParameter = invocation.Method.DeclaringType.GetGenericArguments()[0]; IList result = GenericsUtility.CraeteInstanceOfSomeGeneric(typeof(List <>), genericParameter, new Type[] { }, new object[] { }) as IList; ITimeouts timeOuts = WebDriverUnpackUtility.UnpackWebdriver(locator.SearchContext).Manage().Timeouts(); try { timeOuts.ImplicitlyWait(zeroTimeSpan); waitingForElementList.Timeout = waitingTimeSpan.WaitingDuration; ReadOnlyCollection <IWebElement> found = waitingForElementList.Until(ReturnWaitingFunction(locator, bys)); result = convert(found, genericParameter); } catch (WebDriverTimeoutException ignored) {} finally { timeOuts.ImplicitlyWait(waitingTimeSpan.WaitingDuration); } if (shouldCache && cached == null) { cached = result; } return(result); }
public ElementInterceptor(IEnumerable <By> bys, IElementLocator locator, TimeOutDuration waitingTimeSpan, bool shouldCache) : base(bys, locator, waitingTimeSpan, shouldCache) { driver = WebDriverUnpackUtility.UnpackWebdriver(locator.SearchContext); }