Skip to main content
Skip table of contents

Other helper functions

The following functions may be used to extend the standard functionality of Cypress. Please note that Cypress is under active development, and the project routinely adds new features. When possible users should adopt the features included in Cypress.

File uploads

Please note that since Cypress 9.3.0, Cypress has included a feature to upload files called .selectFile(). When possible users should make use of the core functions of Cypress.

Function

cy.upload(fileName, fileType)

File uploads are not yet natively supported in Cypress. We have a custom command for uploading files that’s based off of this workaround. It must be chained from a command that retrieves an upload input element.

NONE
cy.findByText('Upload', { selector: 'button' }).upload(
  'src/platform/testing/example-upload.png',
  'image/jpg'
);

Source file

upload.js

Description

Allows us to upload files, which Cypress does not natively support. This implementation is based on this workaround.

Arguments

  • fileName - a string

  • fileType - a string

This function must be chained from a command that retrieves an upload input element.

CODE
cy.findByText('Upload', { selector: 'button' }).upload(
  'src/platform/testing/example-upload.png',
  'image/jpg'
);

Expand Accordions

Function

cy.expandAccordions()

Source file

explandAccordions.js

Description

The custom command cy.expandAccordions() expands all accordions and AdditionalInfo components.

Arguments

None


JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.