Skip to content

cy.selectFile() not finding file when executing github action #31726

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
kathleennaughton opened this issue May 15, 2025 · 2 comments
Open

cy.selectFile() not finding file when executing github action #31726

kathleennaughton opened this issue May 15, 2025 · 2 comments
Labels
stage: awaiting response Potential fix was proposed; awaiting response

Comments

@kathleennaughton
Copy link

kathleennaughton commented May 15, 2025

Current behavior

My tests are failing with the following error when executing in github action (these pass on local execution):

CypressError: cy.selectFile("/home/runner/work/qa-cypress/qa-cypress/cypress/downloads/PersonalTaxReturn.jpg") failed because the file does not exist at the following path:

/home/runner/work/qa-cypress/qa-cypress/cypress/downloads/PersonalTaxReturn.jpg

I have verified that this file exists in my github runner image:
Run echo "Absolute path to cypress/downloads:"
Absolute path to cypress/downloads:

/home/runner/work/qa-cypress/qa-cypress/cypress/downloads
total [6](**REDACTED ****)80
drwxr-xr-x 2 runner docker   4096 May 15 1[7](https:**REDACTED ****):35 .
drwxr-xr-x 7 runner docker   4096 May 15 17:35 ..
-rw-r--r-- 1 runner docker   614[8](https:**REDACTED ****) May 15 17:35 .DS_Store
-rw-r--r-- 1 runner docker 173527 May 15 17:35 BankStatement3Month.pdf
-rw-r--r-- 1 runner docker 173527 May 15 17:35 BankStatement6Month.pdf
-rw-r--r-- 1 runner docker 14132[9](**REDACTED ****) May 15 17:35 BusinessTaxReturn.jpg
-rw-r--r-- 1 runner docker  38719 May 15 17:35 GovermentID.jpg
-rw-r--r-- 1 runner docker 141329 May 15 17:35 PersonalTaxReturn.jpg

Please correct this issue.

Desired behavior

cy.selectFile() works in github action the same as in local exeuction

Test code to reproduce

 it.only("can add note to uploaded file", () => {
    const filePath = `${Cypress.config("fileServerFolder")}/cypress/downloads/PersonalTaxReturn.jpg`;
    cy.get("input[type=file]").first().selectFile(filePath, {
      force: true,
    }); // force: true is needed to bypass the hidden input field
    cy.wait(1000); // wait for the file to upload
    
    // clean up the uploaded file by removing it
    cy.get(removeIcon).contains(localizedString("Remove")).click();
    cy.wait(2000);
    // Verify that all remove buttons are gone
    cy.get(removeIcon).contains(localizedString("Remove")).should("not.exist");
  });

Cypress Version

14.3.2

Node version

23.11.1

Operating System

Download action repository 'cypress-io/github-action@v6'

Debug Logs

Other

No response

@jennifer-shehane
Copy link
Member

@kathleennaughton I believe you may need to provide a path relative to the Cypress project root. The docs specify this:

If given a path, .selectFile() will search for the file relative to the project root and attach the file exactly as it exists on disk.

https://docs.cypress.io/api/commands/selectfile#From-a-file-on-disk

@jennifer-shehane jennifer-shehane added the stage: awaiting response Potential fix was proposed; awaiting response label May 20, 2025
@kathleennaughton
Copy link
Author

@jennifer-shehane I have tried relative and absolute path and get the same result:

For sanity's sake, have yml step to list path and files:
Absolute path:
/home/runner/work/qa-cypress/qa-cypress/cypress/downloads
total 680
drwxr-xr-x 2 runner docker 4096 May 20 22:01 .
drwxr-xr-x 7 runner docker 4096 May 20 22:01 ..
-rw-r--r-- 1 runner docker 6148 May 20 22:01 .DS_Store
-rw-r--r-- 1 runner docker 173527 May 20 22:01 BankStatement3Month.pdf
-rw-r--r-- 1 runner docker 173527 May 20 22:01 BankStatement6Month.pdf
-rw-r--r-- 1 runner docker 141329 May 20 22:01 BusinessTaxReturn.jpg
-rw-r--r-- 1 runner docker 38719 May 20 22:01 GovermentID.jpg
-rw-r--r-- 1 runner docker 141329 May 20 22:01 PersonalTaxReturn.jpg

Test with relative path:
CypressError: cy.selectFile("cypress/downloads/BankStatement3Month.pdf") failed because the file does not exist at the following path:
/home/runner/work/qa-cypress/qa-cypress/cypress/downloads/BankStatement3Month.pdf

Test with that uses ${Cypress.config("fileServerFolder")}/cypress/downloads/PersonalTaxReturn.jpg
for doc path:
CypressError: cy.selectFile("/home/runner/work/qa-cypress/qa-cypress/cypress/downloads/PersonalTaxReturn.jpg") failed because the file does not exist at the following path:

/home/runner/work/qa-cypress/qa-cypress/cypress/downloads/PersonalTaxReturn.jpg

From what I can see, my runner image has the files and the path is the same with either relative or absolute defined in tests.

The image info:
Operating System
Ubuntu
22.04.5
LTS
Runner Image
Image: ubuntu-22.04
Version: 20250511.1.0

Please advise if I am missing something that I'm not seeing or what next steps should be.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stage: awaiting response Potential fix was proposed; awaiting response
Projects
None yet
Development

No branches or pull requests

2 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy