/// <summary> /// Returns a <see cref="Dictionary{TKey, TValue}"/> with property names as keys and <see cref="JSHandle"/> instances for the property values. /// </summary> /// <returns>Task which resolves to a <see cref="Dictionary{TKey, TValue}"/></returns> /// <example> /// <code> /// var handle = await page.EvaluateExpressionHandle("({window, document})"); /// var properties = await handle.GetPropertiesAsync(); /// var windowHandle = properties["window"]; /// var documentHandle = properties["document"]; /// await handle.DisposeAsync(); /// </code> /// </example> public async Task <Dictionary <string, JSHandle> > GetPropertiesAsync() { var response = await Client.SendAsync("Runtime.getProperties", new { objectId = RemoteObject[MessageKeys.ObjectId].AsString(), ownProperties = true }).ConfigureAwait(false); var result = new Dictionary <string, JSHandle>(); foreach (var property in response[MessageKeys.Result]) { if (property[MessageKeys.Enumerable] == null) { continue; } result.Add(property[MessageKeys.Name].AsString(), ExecutionContext.CreateJSHandle(property[MessageKeys.Value])); } return(result); }
/// <summary> /// Returns a <see cref="Dictionary{TKey, TValue}"/> with property names as keys and <see cref="JSHandle"/> instances for the property values. /// </summary> /// <returns>Task which resolves to a <see cref="Dictionary{TKey, TValue}"/></returns> /// <example> /// <code> /// var handle = await page.EvaluateExpressionHandle("({window, document})"); /// var properties = await handle.GetPropertiesAsync(); /// var windowHandle = properties["window"]; /// var documentHandle = properties["document"]; /// await handle.DisposeAsync(); /// </code> /// </example> public async Task <Dictionary <string, JSHandle> > GetPropertiesAsync() { var response = await Client.SendAsync <RuntimeGetPropertiesResponse>("Runtime.getProperties", new RuntimeGetPropertiesRequest { ObjectId = RemoteObject.ObjectId, OwnProperties = true }).ConfigureAwait(false); var result = new Dictionary <string, JSHandle>(); foreach (var property in response.Result) { if (property.Enumerable == null) { continue; } result.Add(property.Name, ExecutionContext.CreateJSHandle(property.Value)); } return(result); }
/// <summary> /// Returns a <see cref="Dictionary{TKey, TValue}"/> with property names as keys and <see cref="JSHandle"/> instances for the property values. /// </summary> /// <returns>Task which resolves to a <see cref="Dictionary{TKey, TValue}"/></returns> /// <example> /// <code> /// var handle = await page.EvaluateExpressionHandle("({window, document})"); /// var properties = await handle.GetPropertiesAsync(); /// var windowHandle = properties["window"]; /// var documentHandle = properties["document"]; /// await handle.DisposeAsync(); /// </code> /// </example> public async Task <Dictionary <string, JSHandle> > GetPropertiesAsync() { var response = await Client.SendAsync("Runtime.getProperties", new { objectId = RemoteObject.objectId.ToString(), ownProperties = true }).ConfigureAwait(false); var result = new Dictionary <string, JSHandle>(); foreach (var property in response.result) { if (property.enumerable == null) { continue; } result.Add(property.name.ToString(), ExecutionContext.CreateJSHandle(property.value)); } return(result); }