MCPcopy
hub / github.com/vercel/next.js / webdriver

Function webdriver

test/lib/next-webdriver.ts:107–224  ·  view source on GitHub ↗
(
  appPortOrUrl: string | number,
  url: string,
  options?: WebdriverOptions
)

Source from the content-addressed store, hash-verified

105 * @returns thenable browser instance
106 */
107export default async function webdriver(
108 appPortOrUrl: string | number,
109 url: string,
110 options?: WebdriverOptions
111): Promise<Playwright> {
112 const defaultOptions = {
113 waitHydration: true,
114 retryWaitHydration: false,
115 disableCache: false,
116 }
117 options = Object.assign(defaultOptions, options)
118 const {
119 waitHydration,
120 retryWaitHydration,
121 disableCache,
122 beforePageLoad,
123 extraHTTPHeaders,
124 locale,
125 disableJavaScript,
126 permissions,
127 ignoreHTTPSErrors,
128 headless,
129 cpuThrottleRate,
130 pushErrorAsConsoleLog,
131 userAgent,
132 waitUntil,
133 } = options
134
135 const { Playwright, quit } = await import('./browsers/playwright')
136 browserQuit = quit
137
138 const browser = new Playwright()
139 const browserName = process.env.BROWSER_NAME || 'chrome'
140 await browser.setup(
141 browserName,
142 locale!,
143 !disableJavaScript,
144 Boolean(ignoreHTTPSErrors),
145 // allow headless to be overwritten for a particular test
146 typeof headless !== 'undefined' ? headless : !!process.env.HEADLESS,
147 userAgent,
148 permissions
149 )
150 ;(global as any).browserName = browserName
151
152 const fullUrl = getFullUrl(
153 appPortOrUrl,
154 url,
155 isBrowserStack ? deviceIP : 'localhost'
156 )
157
158 debugPrint(`Loading browser with ${fullUrl}`)
159
160 await browser.loadPage(fullUrl, {
161 disableCache,
162 cpuThrottleRate,
163 beforePageLoad,
164 extraHTTPHeaders,

Callers 15

index.test.tsFile · 0.85
runTestsFunction · 0.85
index.test.tsFile · 0.85
navigateTestFunction · 0.85
index.test.tsFile · 0.85
runTestsFunction · 0.85
index.test.tsFile · 0.85
runTestsFunction · 0.85
index.test.tsFile · 0.85
index.test.tsFile · 0.85
runTestsFunction · 0.85
runTestsFunction · 0.85

Calls 10

setupMethod · 0.95
loadPageMethod · 0.95
getFullUrlFunction · 0.90
debugPrintFunction · 0.90
checkHydratedFunction · 0.85
assignMethod · 0.80
pushMethod · 0.65
errorMethod · 0.65
setTimeoutFunction · 0.50
bindMethod · 0.45

Tested by 15

runTestsFunction · 0.68
navigateTestFunction · 0.68
runTestsFunction · 0.68
runTestsFunction · 0.68
runTestsFunction · 0.68
runTestsFunction · 0.68
runTestsFunction · 0.68
runTestsFunction · 0.68
runTestsFunction · 0.68
runTestsFunction · 0.68
runTestsFunction · 0.68
runTestsFunction · 0.68