upload image from Computer in cypress io script code example
Example 1: upload image cypress
cy.fixture('images/logo.png').as('logo')
cy.get('input[type=file]').then(function($input) {
return Cypress.Blob.base64StringToBlob(this.logo, 'image/png')
.then((blob) => {
$input.fileupload('add', { files: blob })
})
})
Example 2: upload photos cypress
cy.fixture('path/to/image.png').as('logo')
.get('input[type=file]').then(function(el) {
return Cypress.Blob.base64StringToBlob(this.logo, 'image/png')
.then(blob => {
el[0].files[0] = blob
el[0].dispatchEvent(new Event('change', {bubbles: true}))
})
})