I need to upload a file, but the thing is that the button doesn't have the tag input and attr type="file". How do I solve this?
The DOM:
I tried:
cy.contains('div#dropdown-grouped', "Bon d'intervention").siblings('div.d-none').find('input[type="file"]')
.selectFile('cypress/fixtures/bon.pdf', {force: true})
But this returns a statusCode 422
Also tried:
const filePath = 'My reportis.jpg'
cy.contains('#dropdown-group-1', "Bon d'intervention").attachFile(filepath)
But this obviously does nothing.
What if I would change the tag of the button from button to input, and add an attr type="file", would that work? If yes, how do you I change the tag with cypress?
Thank you very much!
Solution:
cy.contains('#dropdown-group-1', "Bon d'intervention").click()
cy.get('input[type="file"]').selectFile('cypress/fixtures/bon.pdf', {force: true})