Complete the code to select a file for upload in Cypress.
cy.get('input[type="file"]').[1]('example.txt');
The attachFile command is used in Cypress to simulate file upload by attaching a file to an input element.
Complete the code to check if the uploaded file name is visible after upload.
cy.get('.uploaded-file-name').should('[1]', 'example.txt');
The have.text assertion checks that the element's text exactly matches the given string, which is suitable for verifying the uploaded file name.
Fix the error in the code that verifies the downloaded file content.
cy.readFile('cypress/downloads/[1]').should('include', 'Success');
The default downloaded file name is often 'download.txt' unless renamed. Using the correct file name ensures the test reads the right file.
Fill both blanks to upload a file and verify the upload success message.
cy.get('input[type="file"]').[1]('report.pdf'); cy.get('.upload-status').should('[2]', 'Upload successful');
Use attachFile to upload the file, and contain.text to check that the success message includes the expected text.
Fill all three blanks to read a downloaded file, check its size, and confirm content.
cy.readFile('cypress/downloads/[1]').then((content) => { expect(content.length).to.be.[2](1000); expect(content).to.[3]('Download complete'); });
The file name is 'download.txt'. The test checks that the content length is above 1000 characters and that the content includes the phrase 'Download complete'.