public async Task <Dictionary <string, object> > GetProperty(string propertyName) { dynamic response = await _client.SendAsync("Runtime.getProperties", new Dictionary <string, object>() { { "objectId", RemoteObject.ObjectId }, { "ownProperties", true } }); var result = new Dictionary <string, object>(); foreach (var property in response.result) { result.Add(property.name.ToString(), _context.ObjectHandleFactory(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 }); var result = new Dictionary <string, JSHandle>(); foreach (var property in response.result) { if (property.enumerable == null) { continue; } result.Add(property.name.ToString(), _context.ObjectHandleFactory(property.value)); } return(result); }