def __init__(self, client: CDPSession, frameTree: Dict, page: Any) -> None: """Make new frame manager.""" super().__init__() self._client = client self._page = page self._frames: OrderedDict[str, Frame] = OrderedDict() self._mainFrame: Optional[Frame] = None self._contextIdToContext: Dict[str, ExecutionContext] = dict() client.on('Page.frameAttached', lambda event: self._onFrameAttached( event.get('frameId', ''), event.get('parentFrameId', '')) ) client.on('Page.frameNavigated', lambda event: self._onFrameNavigated(event.get('frame'))) client.on('Page.navigatedWithinDocument', lambda event: self._onFrameNavigatedWithinDocument( event.get('frameId'), event.get('url') )) client.on('Page.frameDetached', lambda event: self._onFrameDetached(event.get('frameId'))) client.on('Page.frameStoppedLoading', lambda event: self._onFrameStoppedLoading( event.get('frameId') )) client.on('Runtime.executionContextCreated', lambda event: self._onExecutionContextCreated( event.get('context'))) client.on('Runtime.executionContextDestroyed', lambda event: self._onExecutionContextDestroyed( event.get('executionContextId'))) client.on('Runtime.executionContextsCleared', lambda event: self._onExecutionContextsCleared()) client.on('Page.lifecycleEvent', lambda event: self._onLifecycleEvent(event)) self._handleFrameTree(frameTree)
def __init__(self, client: CDPSession, frameTree: Dict, page: Any) -> None: """Make new frame manager.""" super().__init__() self._client = client self._page = page self._frames: OrderedDict[str, Frame] = OrderedDict() self._mainFrame: Optional[Frame] = None self._contextIdToContext: Dict[str, ExecutionContext] = dict() client.on('Page.frameAttached', lambda event: self._onFrameAttached( event.get('frameId', ''), event.get('parentFrameId', '')) ) client.on('Page.frameNavigated', lambda event: self._onFrameNavigated(event.get('frame'))) client.on('Page.frameDetached', lambda event: self._onFrameDetached(event.get('frameId'))) client.on('Runtime.executionContextCreated', lambda event: self._onExecutionContextCreated( event.get('context'))) client.on('Runtime.executionContextDestroyed', lambda event: self._onExecutionContextDestroyed( event.get('executionContextId'))) client.on('Runtime.executionContextsCleared', lambda event: self._onExecutionContextsCleared()) client.on('Page.lifecycleEvent', lambda event: self._onLifecycleEvent(event)) self._handleFrameTree(frameTree)
def __init__(self, client: CDPSession, frameTree: Dict, page: Any) -> None: 'Make new frame manager.' super().__init__() self._client = client self._page = page self._frames = OrderedDict() self._mainFrame = None self._contextIdToContext = dict() client.on('Page.frameAttached', (lambda event: self._onFrameAttached( event.get('frameId', ''), event.get('parentFrameId', '')))) client.on('Page.frameNavigated', (lambda event: self._onFrameNavigated(event.get('frame')))) client.on('Page.navigatedWithinDocument', (lambda event: self._onFrameNavigatedWithinDocument( event.get('frameId'), event.get('url')))) client.on('Page.frameDetached', (lambda event: self._onFrameDetached(event.get('frameId')))) client.on( 'Page.frameStoppedLoading', (lambda event: self._onFrameStoppedLoading(event.get('frameId')))) client.on('Runtime.executionContextCreated', (lambda event: self._onExecutionContextCreated( event.get('context')))) client.on('Runtime.executionContextDestroyed', (lambda event: self._onExecutionContextDestroyed( event.get('executionContextId')))) client.on('Runtime.executionContextsCleared', (lambda event: self._onExecutionContextsCleared())) client.on('Page.lifecycleEvent', (lambda event: self._onLifecycleEvent(event))) self._handleFrameTree(frameTree)
def __init__(self, client: CDPSession, target: 'Target', frameTree: Dict, ignoreHTTPSErrors: bool = False, screenshotTaskQueue: list = None, ) -> None: super().__init__() self._client = client self._target = target self._keyboard = Keyboard(client) self._mouse = Mouse(client, self._keyboard) self._touchscreen = Touchscreen(client, self._keyboard) self._frameManager = FrameManager(client, frameTree, self) self._networkManager = NetworkManager(client, self._frameManager) self._emulationManager = EmulationManager(client) self._tracing = Tracing(client) self._pageBindings: Dict[str, Callable] = dict() self._ignoreHTTPSErrors = ignoreHTTPSErrors self._defaultNavigationTimeout = 30000 # milliseconds self._coverage = Coverage(client) if screenshotTaskQueue is None: screenshotTaskQueue = list() self._screenshotTaskQueue = screenshotTaskQueue _fm = self._frameManager _fm.on(FrameManager.Events.FrameAttached, lambda event: self.emit(Page.Events.FrameAttached, event)) _fm.on(FrameManager.Events.FrameDetached, lambda event: self.emit(Page.Events.FrameDetached, event)) _fm.on(FrameManager.Events.FrameNavigated, lambda event: self.emit(Page.Events.FrameNavigated, event)) _nm = self._networkManager _nm.on(NetworkManager.Events.Request, lambda event: self.emit(Page.Events.Request, event)) _nm.on(NetworkManager.Events.Response, lambda event: self.emit(Page.Events.Response, event)) _nm.on(NetworkManager.Events.RequestFailed, lambda event: self.emit(Page.Events.RequestFailed, event)) _nm.on(NetworkManager.Events.RequestFinished, lambda event: self.emit(Page.Events.RequestFinished, event)) client.on('Page.loadEventFired', lambda event: self.emit(Page.Events.Load)) client.on('Runtime.consoleAPICalled', lambda event: self._onConsoleAPI(event)) client.on('Page.javascriptDialogOpening', lambda event: self._onDialog(event)) client.on('Runtime.exceptionThrown', lambda exception: self._handleException( exception.get('exceptionDetails'))) client.on('Security.certificateError', lambda event: self._onCertificateError(event)) client.on('Inspector.targetCrashed', lambda event: self._onTargetCrashed()) client.on('Performance.metrics', lambda event: self._emitMetrics(event))
def __init__( self, client: CDPSession, target: 'Target', frameTree: Dict, ignoreHTTPSErrors: bool = False, screenshotTaskQueue: list = None, ) -> None: super().__init__() self._client = client self._target = target self._keyboard = Keyboard(client) self._mouse = Mouse(client, self._keyboard) self._touchscreen = Touchscreen(client, self._keyboard) self._frameManager = FrameManager(client, frameTree, self) self._networkManager = NetworkManager(client, self._frameManager) self._emulationManager = EmulationManager(client) self._tracing = Tracing(client) self._pageBindings: Dict[str, Callable] = dict() self._ignoreHTTPSErrors = ignoreHTTPSErrors self._defaultNavigationTimeout = 30000 # milliseconds self._coverage = Coverage(client) if screenshotTaskQueue is None: screenshotTaskQueue = list() self._screenshotTaskQueue = screenshotTaskQueue _fm = self._frameManager _fm.on(FrameManager.Events.FrameAttached, lambda event: self.emit(Page.Events.FrameAttached, event)) _fm.on(FrameManager.Events.FrameDetached, lambda event: self.emit(Page.Events.FrameDetached, event)) _fm.on(FrameManager.Events.FrameNavigated, lambda event: self.emit(Page.Events.FrameNavigated, event)) _nm = self._networkManager _nm.on(NetworkManager.Events.Request, lambda event: self.emit(Page.Events.Request, event)) _nm.on(NetworkManager.Events.Response, lambda event: self.emit(Page.Events.Response, event)) _nm.on(NetworkManager.Events.RequestFailed, lambda event: self.emit(Page.Events.RequestFailed, event)) _nm.on(NetworkManager.Events.RequestFinished, lambda event: self.emit(Page.Events.RequestFinished, event)) client.on('Page.loadEventFired', lambda event: self.emit(Page.Events.Load)) client.on('Runtime.consoleAPICalled', lambda event: self._onConsoleAPI(event)) client.on('Page.javascriptDialogOpening', lambda event: self._onDialog(event)) client.on( 'Runtime.exceptionThrown', lambda exception: self._handleException( exception.get('exceptionDetails'))) client.on('Security.certificateError', lambda event: self._onCertificateError(event)) client.on('Inspector.targetCrashed', lambda event: self._onTargetCrashed()) client.on('Performance.metrics', lambda event: self._emitMetrics(event))
def __init__(self, client: CDPSession, page: Any, ignoreHTTPSErrors) -> None: """Make new frame manager.""" super().__init__() self._client = client self._page = page self._networkmanager = NetworkManager(client, self, ignoreHTTPSErrors) self._frames: OrderedDict[str, Frame] = OrderedDict() self._mainFrame: Optional[Frame] = None self._contextIdToContext: Dict[str, ExecutionContext] = dict() self._isolatedWorlds = set() client.on( 'Page.frameAttached', lambda event: self._onFrameAttached( event.get('frameId', ''), event.get('parentFrameId', ''))) client.on('Page.frameNavigated', lambda event: self._onFrameNavigated(event.get('frame'))) client.on( 'Page.navigatedWithinDocument', lambda event: self._onFrameNavigatedWithinDocument( event.get('frameId'), event.get('url'))) client.on('Page.frameDetached', lambda event: self._onFrameDetached(event.get('frameId'))) client.on( 'Page.frameStoppedLoading', lambda event: self._onFrameStoppedLoading(event.get('frameId'))) client.on( 'Runtime.executionContextCreated', lambda event: self. _onExecutionContextCreated(event.get('context'))) client.on( 'Runtime.executionContextDestroyed', lambda event: self._onExecutionContextDestroyed( event.get('executionContextId'))) client.on('Runtime.executionContextsCleared', lambda event: self._onExecutionContextsCleared()) client.on('Page.lifecycleEvent', lambda event: self._onLifecycleEvent(event))