public static async Task <object> GetReturnValue(this IInvocation invocation, ElementObject elementObject, SelectorAttribute attribute) { var element = elementObject.Element; if (element == null) { return(null); } if (invocation.IsReturning <ElementHandle>()) { return(await element.QuerySelectorAsync(attribute.Selector).ConfigureAwait(false)); } if (invocation.IsReturning <ElementHandle[]>()) { return(await element.QuerySelectorAllAsync(attribute.Selector).ConfigureAwait(false)); } if (invocation.IsReturningElementObject()) { var proxyType = invocation.Method.ReturnType.GetGenericArguments()[0]; var elementHandle = await element.QuerySelectorAsync(attribute.Selector).ConfigureAwait(false); return(ProxyFactory.ElementObject(proxyType, elementObject.Page, elementHandle)); } if (invocation.IsReturningElementObjectArray()) { var arrayType = invocation.Method.ReturnType.GetGenericArguments()[0]; var proxyType = arrayType.GetElementType(); var elementHandles = await element.QuerySelectorAllAsync(attribute.Selector).ConfigureAwait(false); return(ProxyFactory.ElementObjectArray(proxyType, elementObject.Page, elementHandles)); } return(null); }