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

Method saveElementScreenshot

lib/helper/Puppeteer.js:2205–2214  ·  view source on GitHub ↗

* {{> saveElementScreenshot }}

(locator, fileName)

Source from the content-addressed store, hash-verified

2203 * {{> saveElementScreenshot }}
2204 */
2205 async saveElementScreenshot(locator, fileName) {
2206 const outputFile = screenshotOutputFolder(fileName)
2207
2208 const res = await this._locate(locator)
2209 assertElementExists(res, locator)
2210 if (res.length > 1) this.debug(`[Elements] Using first element out of ${res.length}`)
2211 const elem = res[0]
2212 this.debug(`Screenshot of ${new Locator(locator)} element has been saved to ${outputFile}`)
2213 return elem.screenshot({ path: outputFile, type: 'png' })
2214 }
2215
2216 /**
2217 * {{> saveScreenshot }}

Callers 3

testsFunction · 0.45

Calls 4

_locateMethod · 0.95
screenshotOutputFolderFunction · 0.90
debugMethod · 0.80
assertElementExistsFunction · 0.70

Tested by

no test coverage detected