MCPcopy
hub / github.com/blitz-js/blitz / loadPage

Method loadPage

integration-tests/utils/browsers/playwright.ts:62–103  ·  view source on GitHub ↗
(
    url: string,
    opts?: {disableCache: boolean; beforePageLoad?: (...args: any[]) => void},
  )

Source from the content-addressed store, hash-verified

60 }
61
62 async loadPage(
63 url: string,
64 opts?: {disableCache: boolean; beforePageLoad?: (...args: any[]) => void},
65 ) {
66 // clean-up existing pages
67 for (const oldPage of context!.pages()) {
68 await oldPage.close()
69 }
70 page = await context!.newPage()
71 pageLogs = []
72 websocketFrames = []
73
74 page.on("console", (msg) => {
75 console.log("browser log:", msg)
76 pageLogs.push({source: msg.type(), message: msg.text()})
77 })
78 page.on("crash", (page) => {
79 console.error("page crashed")
80 })
81 page.on("pageerror", (error) => {
82 console.error("page error", error)
83 })
84 page.on("request", (req) => {
85 this.eventCallbacks.request.forEach((cb) => cb(req))
86 })
87
88 if (opts?.disableCache) {
89 // TODO: this doesn't seem to work (dev tools does not check the box as expected)
90 const session = await context!.newCDPSession(page)
91 session.send("Network.setCacheDisabled", {cacheDisabled: true})
92 }
93
94 page.on("websocket", (ws) => {
95 ws.on("framereceived", (frame) => {
96 websocketFrames.push({payload: frame.payload})
97 })
98 })
99
100 opts?.beforePageLoad?.(page)
101
102 await page.goto(url, {waitUntil: "load"})
103 }
104
105 back(): BrowserInterface {
106 return this.chain(() => {

Callers

nothing calls this directly

Calls 6

errorMethod · 0.80
closeMethod · 0.45
onMethod · 0.45
logMethod · 0.45
typeMethod · 0.45
textMethod · 0.45

Tested by

no test coverage detected