I am trying to create a Cypress test that decodes a QR code from a webpage/pdf. I managed to take a screenshot using cy.screenshot(), but I don't find a way to extract the information from the QR image/PNG. Here is what I've tried using @nuintun/qrcode but I get an error: Failed to load image...
it('Takes QR Code Screenshot and Read QR Image', () => {
cy.get('#image').screenshot('qrcode', {
onAfterScreenshot($el, props) {
console.log('========Test1======', props)
qrcode
.scan(props.path)
.then(result => {
console.log('=====Test2=====', result);
})
}
})
Instead of qrcode.scan I could use qrcode.decode, but I don't know how to transform the local PNG image to Uint8ClampedArray in a Cypress test using JavaScript. Any suggestions ?
decode(data: Uint8ClampedArray, width: number, height: number): DecoderResult