Skip to content

cy.selectFile() must only be invoked from the spec file or support file. #29800

Closed as not planned
@gmaggiodev

Description

@gmaggiodev

Current behavior

After upgrading to latest version of Cypress, when I try to upload a file using cy.selectFile() I got an error (cy.selectFile() must only be invoked from the spec file or support file.). The same code works with Cypress 11.14.0.

Desired behavior

Should work as version 11.14.0

Test code to reproduce

Using cucumber preprocessor I have this rule that is not wotking anymore:

When('the user upload the file {string}', (fileName: string) => {
    cy.get('tf-uploader input[type="file"]').selectFile(`cypress/files/${fileName}`);
});

Cypress Version

13.13.0

Node version

v18.19.0

Operating System

Windows 11

Debug Logs

at <unknown> (https://<###removed###>/__cypress/runner/cypress_runner.js:114038:70)
    at tryCatcher (https://<### removed ###>/__cypress/runner/cypress_runner.js:1807:23)
    at Promise._settlePromiseFromHandler (https://<### removed ###>/__cypress/runner/cypress_runner.js:1519:31)
    at Promise._settlePromise (https://<### removed ###>/__cypress/runner/cypress_runner.js:1576:18)
    at Promise._settlePromise0 (https://<### removed ###>/__cypress/runner/cypress_runner.js:1621:10)
    at Promise._settlePromises (https://<### removed ###>/__cypress/runner/cypress_runner.js:1697:18)
    at <unknown> (https://<### removed ###>/__cypress/runner/cypress_runner.js:2392:25)
From previous event:
    at Promise.longStackTracesCaptureStackTrace [as _captureStackTrace] (https://<### removed ###>/__cypress/runner/cypress_runner.js:3486:19)
    at Promise._then (https://<### removed ###>/__cypress/runner/cypress_runner.js:1239:17)
    at Promise.then (https://<### removed ###>/__cypress/runner/cypress_runner.js:1132:17)
    at next (https://<### removed ###>/__cypress/runner/cypress_runner.js:144081:64)
    at <unknown> (https://<### removed ###>/__cypress/runner/cypress_runner.js:144102:16)
    at tryCatcher (https://<### removed ###>/__cypress/runner/cypress_runner.js:1807:23)
    at Promise._settlePromiseFromHandler (https://<### removed ###>/__cypress/runner/cypress_runner.js:1519:31)
    at Promise._settlePromise (https://<### removed ###>/__cypress/runner/cypress_runner.js:1576:18)
    at Promise._settlePromise0 (https://<### removed ###>/__cypress/runner/cypress_runner.js:1621:10)
    at Promise._settlePromises (https://<### removed ###>/__cypress/runner/cypress_runner.js:1701:18)
    at <unknown> (https://<### removed ###>/__cypress/runner/cypress_runner.js:2392:25)
From Your Spec Code:
    at Context.eval (https://<### removed ###>/__cypress/tests?p=cypress\features\7-provisioning%20tools\Marketplace%20Packages'%20Test\PT0009-Package%20Installation%20Job%20Vacancy%20Report.feature:21076:50)
    at Registry.runStepDefininition (https://<### removed ###>/__cypress/tests?p=cypress\features\7-provisioning%20tools\Marketplace%20Packages'%20Test\PT0009-Package%20Installation%20Job%20Vacancy%20Report.feature:8508:48)
    at Object.fn (https://<### removed ###>/__cypress/tests?p=cypress\features\7-provisioning%20tools\Marketplace%20Packages'%20Test\PT0009-Package%20Installation%20Job%20Vacancy%20Report.feature:15707:43)
    at runStepWithLogGroup (https://<### removed ###>/__cypress/tests?p=cypress\features\7-provisioning%20tools\Marketplace%20Packages'%20Test\PT0009-Package%20Installation%20Job%20Vacancy%20Report.feature:15180:29)
    at Context.eval (https://<### removed ###>/__cypress/tests?p=cypress\features\7-provisioning%20tools\Marketplace%20Packages'%20Test\PT0009-Package%20Installation%20Job%20Vacancy%20Report.feature:15703:62)

Other

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions