MCPcopy Create free account
hub / github.com/omkarcloud/botasaurus / createPlaywright

Function createPlaywright

js/botasaurus-js/src/playwright.ts:147–433  ·  view source on GitHub ↗
(
    options: PlaywrightOptions<I>,
    is_async_queue: boolean
)

Source from the content-addressed store, hash-verified

145let isChromeInstalled = true;
146
147function createPlaywright<I>(
148 options: PlaywrightOptions<I>,
149 is_async_queue: boolean
150) {
151 const _driverPool: PlaywrightChrome[] = [];
152
153 const performPlaywright = async function (
154 data: any = null,
155 overrideOptions: Omit<PlaywrightOptions<any>, "run"> = {}
156 ) {
157 const combined = { ...options, ...overrideOptions };
158 printRunning();
159 if (!isChromeInstalled) {
160 throw chromeNotInstalledError();
161 }
162
163 let {
164 parallel = 1,
165 name = null,
166 run,
167 metadata = null,
168 cache = null,
169 // beep = false,
170 closeOnCrash = false,
171 output = "default",
172 outputFormats = null,
173 raiseException = false,
174 mustRaiseExceptions = null,
175 maxRetry = null,
176 retryWait = null,
177 createErrorLogs = true,
178 reuseDriver = false,
179 headless = false,
180 userAgent = null
181 } = combined;
182
183 performPlaywright.__name__ = isNotEmptyString(name)
184 ? name!.trim()
185 : performPlaywright.__name__;
186 // @ts-ignore
187 const returnDontCacheAsIs = combined.returnDontCacheAsIs;
188 // @ts-ignore
189 const isAborted = combined.isAborted ?? (() => false);
190 // @ts-ignore
191 const pushData = combined.pushData ?? (() => {});
192 // @ts-ignore
193 const taskId = combined.taskId ?? null;
194 // @ts-ignore
195 const parentTaskId = combined.parentTaskId ?? null;
196 const fn_name = performPlaywright.__name__;
197
198 if (cache) {
199 createCacheDirectoryIfNotExists(fn_name);
200 }
201
202 async function runPlaywright(
203 data: any,
204 retryAttempt: number,

Callers 2

playwrightFunction · 0.85
playwrightQueueFunction · 0.85

Calls 2

isNotEmptyStringFunction · 0.90
closeDriverPoolFunction · 0.85

Tested by

no test coverage detected