예제 #1
0
        public async Task <string> GetOwnerFrameAsync(ElementHandle handle)
        {
            // document.documentElement has frameId of the owner frame.
            var documentElement = await handle.EvaluateHandleAsync(@"node => {
                const doc = node;
                if (doc.documentElement && doc.documentElement.ownerDocument === doc)
                    return doc.documentElement;
                return node.ownerDocument ? node.ownerDocument.documentElement : null;
            }").ConfigureAwait(false) as ElementHandle;

            if (documentElement == null)
            {
                return(null);
            }

            var remoteObject = documentElement.RemoteObject;

            if (string.IsNullOrEmpty(remoteObject.ObjectId))
            {
                return(null);
            }

            var nodeInfo = await Client.SendAsync(new DOMDescribeNodeRequest
            {
                ObjectId = remoteObject.ObjectId,
            }).ConfigureAwait(false);

            string frameId = nodeInfo?.Node?.FrameId;
            await documentElement.DisposeAsync().ConfigureAwait(false);

            return(frameId);
        }
예제 #2
0
 public Task SetInputFilesAsync(ElementHandle handle, IEnumerable <FilePayload> files)
 => handle.EvaluateHandleAsync(Dom.SetFileInputFunction, files);