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); }
private IList convert(ReadOnlyCollection <IWebElement> original, Type genericParameter) { Type generic = typeof(List <>).MakeGenericType(genericParameter); object result = GenericsUtility.CraeteInstanceOfSomeGeneric(typeof(List <>), genericParameter, new Type[] { }, new object[] { }); IList list = result as IList; foreach (var elem in original) { list.Add(elem); } return(list); }