MCPcopy Create free account
hub / github.com/garris/BackstopJS / selectorShot

Function selectorShot

core/util/runPlaywright.js:453–481  ·  view source on GitHub ↗
(s, path)

Source from the content-addressed store, hash-verified

451 } else {
452 // OTHER-SELECTOR screenshot
453 const selectorShot = async (s, path) => {
454 const el = await page.$(s);
455 if (el) {
456 const box = await el.boundingBox();
457 if (box) {
458 // Resize the viewport to screenshot elements outside of the viewport
459 if (config.useBoundingBoxViewportForSelectors !== false) {
460 const bodyHandle = await page.$('body');
461 const boundingBox = await bodyHandle.boundingBox();
462
463 await page.setViewportSize({
464 width: Math.max(viewport.width, Math.ceil(boundingBox.width)),
465 height: Math.max(viewport.height, Math.ceil(boundingBox.height))
466 });
467 }
468
469 const type = el;
470 const params = { captureBeyondViewport: false, path };
471
472 await type.screenshot(params);
473 } else {
474 console.log(chalk.yellow(`Element not visible for capturing: ${s}`));
475 return fs.copy(config.env.backstop + HIDDEN_SELECTOR_PATH, path);
476 }
477 } else {
478 console.log(chalk.magenta(`Element not found for capturing: ${s}`));
479 return fs.copy(config.env.backstop + SELECTOR_NOT_FOUND_PATH, path);
480 }
481 };
482
483 const selectorsShot = async () => {
484 for (let i = 0; i < selectors.length; i++) {

Callers 1

selectorsShotFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected