Open gmaggiodev opened 3 months ago
I am also getting this regularly. It's incredibly frustrating as it is preventing me from deploying any automation that includes attachments. This wasn't such a big deal a few versions ago but now it happens frequently, but not every time. This was also happening with cy.task() but I have since converted my task to a custom command to avoid the issue. I can't seem to find a way to resolve the selectFile() problem though. For some reason this isn't as frequent on macOS (M1 MacBook) but happens on Windows constantly. I've gone through many iterations of functions and custom commands to try to resolve the issue. Also tried running it from the spec file directly and from my commands support file. Here is my latest iteration that is still failing at about a 15% rate of failure. The referenced fixture is a JSON object containing the relative paths for 40 images.
cy.fixture("images").then((images) => {
const keys = Object.keys(images);
const randomCount = Cypress._.random(3, 5); // Select 3 to 5 images
const selectedImages = Cypress._.sampleSize(keys, randomCount);
cy.get("[notes='Upload Images'] ~ input").selectFile(
selectedImages.map((key) => images[key]),
{ force: true }
);
});
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:
Cypress Version
13.13.0
Node version
v18.19.0
Operating System
Windows 11
Debug Logs
Other
No response