MCPcopy Index your code
hub / github.com/codeceptjs/CodeceptJS / _startBrowser

Method _startBrowser

lib/helper/Playwright.js:1166–1206  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1164 }
1165
1166 async _startBrowser() {
1167 // Ensure custom locator strategies are registered before browser launch
1168 // Only init once globally to avoid selector re-registration in workers
1169 if (!defaultSelectorEnginesInitialized) {
1170 await this._init()
1171 }
1172
1173 if (this.isElectron) {
1174 this.browser = await playwright._electron.launch(this.playwrightOptions)
1175 } else if (this.isRemoteBrowser && this.isCDPConnection) {
1176 try {
1177 this.browser = await playwright[this.options.browser].connectOverCDP(this.playwrightOptions)
1178 } catch (err) {
1179 if (err.toString().indexOf('ECONNREFUSED')) {
1180 throw new RemoteBrowserConnectionRefused(err)
1181 }
1182 throw err
1183 }
1184 } else if (this.isRemoteBrowser) {
1185 try {
1186 this.browser = await playwright[this.options.browser].connect(this.playwrightOptions)
1187 } catch (err) {
1188 if (err.toString().indexOf('ECONNREFUSED')) {
1189 throw new RemoteBrowserConnectionRefused(err)
1190 }
1191 throw err
1192 }
1193 } else if (this.playwrightOptions.userDataDir) {
1194 this.browser = await playwright[this.options.browser].launchPersistentContext(this.userDataDir, this.playwrightOptions)
1195 } else {
1196 this.browser = await playwright[this.options.browser].launch(this.playwrightOptions)
1197 }
1198
1199 // works only for Chromium
1200 this.browser.on('targetchanged', target => {
1201 this.debugSection('Url', target.url())
1202 })
1203
1204 this.isRunning = true
1205 return this.browser
1206 }
1207
1208 /**
1209 * Create a new browser context with a page. \

Callers 3

_beforeSuiteMethod · 0.95
_beforeMethod · 0.95
amOnPageMethod · 0.95

Calls 2

_initMethod · 0.95
toStringMethod · 0.45

Tested by

no test coverage detected