MCPcopy Create free account
hub / github.com/seleniumbase/SeleniumBase / RequestPausedTest

Class RequestPausedTest

examples/cdp_mode/raw_req_async.py:16–39  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

14
15
16class RequestPausedTest():
17 async def request_paused_handler(self, event, tab):
18 r = event.request
19 is_image = ".png" in r.url or ".jpg" in r.url or ".gif" in r.url
20 if not is_image: # Let the data through
21 tab.feed_cdp(
22 mycdp.fetch.continue_request(request_id=event.request_id)
23 )
24 else: # Block the data (images)
25 TIMED_OUT = mycdp.network.ErrorReason.TIMED_OUT
26 s = f"{c1}BLOCKING{cr} | {c2}{r.method}{cr} | {r.url}"
27 print(f" >>> ------------\n{s}")
28 tab.feed_cdp(
29 mycdp.fetch.fail_request(event.request_id, TIMED_OUT)
30 )
31
32 async def start_test(self):
33 driver = await cdp_driver.start_async()
34 tab = await driver.get("about:blank")
35 tab.add_handler(mycdp.fetch.RequestPaused, self.request_paused_handler)
36 url = "https://gettyimages.com/photos/firefly-2003-nathan"
37 await driver.get(url)
38 await asyncio.sleep(5)
39 driver.stop()
40
41
42@decorators.print_runtime("RequestPausedTest")

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…