def testAsksMonitoringToStop(self): devtools_connection = MockDevToolsConnection() page_track = PageTrack(devtools_connection) for msg in PageTrackTest._EVENTS[:-1]: page_track.Handle(msg['method'], msg) self.assertFalse(devtools_connection.stop_has_been_called) msg = PageTrackTest._EVENTS[-1] page_track.Handle(msg['method'], msg) self.assertTrue(devtools_connection.stop_has_been_called)
def testStopsLoadingUnknownFrame(self): page_track = PageTrack(None) msg = { 'method': 'Page.frameStoppedLoading', 'params': { 'frameId': '1234.12' } } with self.assertRaises(AssertionError): page_track.Handle(msg['method'], msg)
def testUnknownParent(self): page_track = PageTrack(None) msg = { 'method': 'Page.frameAttached', 'params': { 'frameId': '1234.12', 'parentFrameId': '1234.1' } } with self.assertRaises(AssertionError): page_track.Handle(msg['method'], msg)
def testGetMainFrameId(self): devtools_connection = MockDevToolsConnection() page_track = PageTrack(devtools_connection) for msg in PageTrackTest._EVENTS: page_track.Handle(msg['method'], msg) self.assertEquals('1234.1', page_track.GetMainFrameId())