MCPcopy
hub / github.com/codeceptjs/CodeceptJS / _withinBegin

Method _withinBegin

lib/helper/Playwright.js:1275–1311  ·  view source on GitHub ↗
(locator)

Source from the content-addressed store, hash-verified

1273 }
1274
1275 async _withinBegin(locator) {
1276 if (this.withinLocator) {
1277 throw new Error("Can't start within block inside another within block")
1278 }
1279
1280 const frame = isFrameLocator(locator)
1281
1282 if (frame) {
1283 if (Array.isArray(frame)) {
1284 // For nested frames, build the complete frame path
1285 await this.switchTo(null)
1286
1287 // Build nested frame locator from page
1288 let frameLocatorObj = this.page
1289 for (const frameSelector of frame) {
1290 const selector = buildLocatorString(new Locator(frameSelector, 'css'))
1291 frameLocatorObj = frameLocatorObj.frameLocator(selector)
1292 }
1293
1294 this.frame = frameLocatorObj
1295 this.context = frameLocatorObj
1296 this.contextLocator = null
1297 this.withinLocator = new Locator(frame)
1298 return
1299 }
1300 await this.switchTo(frame)
1301 this.withinLocator = new Locator(frame)
1302 return
1303 }
1304
1305 const el = await this._locateElement(locator)
1306 assertElementExists(el, locator)
1307 this.context = el
1308 this.contextLocator = locator
1309
1310 this.withinLocator = new Locator(locator)
1311 }
1312
1313 async _withinEnd() {
1314 this.withinLocator = null

Callers

nothing calls this directly

Calls 5

switchToMethod · 0.95
_locateElementMethod · 0.95
buildLocatorStringFunction · 0.85
isFrameLocatorFunction · 0.70
assertElementExistsFunction · 0.70

Tested by

no test coverage detected