Select file does not work if type="file" element has display:none property
See original GitHub issueCurrent behavior
I’m getting
Timed out retrying after 15000ms: cy.selectFile() failed because this element is not visible:
If my element has
style="display: none"
While cypress-file-upload had no issues with that.
{force: true} does not help.
Desired behavior
No response
Test code to reproduce
Just run selectFile
Cypress Version
9.3
Other
No response
Issue Analytics
- State:
- Created 2 years ago
- Reactions:4
- Comments:11 (5 by maintainers)
Top Results From Across the Web
Input type file not working if hidden - Stack Overflow
I want to customize my input type file button. For that I have put it inside a span and set its visibility to...
Read more ><input type="file"> - HTML: HyperText Markup Language | MDN
A file input's value attribute contains a string that represents the path to the selected file(s). If no file is selected yet, the...
Read more >How to check input file is empty or not using JavaScript/jQuery
Approach 1: Use element.files.length property to check file is selected or not. If element.files.length property returns 0 then the file is ...
Read more >Lesson 5: Using Javascript to Hide and Show Content
display : none;. Now refresh your page in your browser. What happened? If everything worked properly, your clock should no longer be visible....
Read more >Styling & Customizing File Inputs the Smart Way - Codrops
Interesting thing is that, if it is a file input, it works out as a click ... such as display: none or visibility:...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
So we have a unit test covering this, which you can see here: https://github.com/cypress-io/cypress/blob/develop/packages/driver/cypress/integration/commands/actions/selectFile_spec.js#L459 https://github.com/cypress-io/cypress/blob/develop/packages/driver/cypress/fixtures/files-form.html#L33
My guess is that you’re setting {force: true} on the first argument, rather than the second.
This is something we could have made more explicit in the migration guide. Basically - the first argument is the file/files being uploaded (file name, contents), and the second argument configures how the command behaves (force, action, timeout).
If you’re still seeing an issue after verifying this, a reproducible example and a more detailed report would help us track down what’s going on.
This sounds like a separate issue, likely related to reading the file from disk; I’d suggest opening a new ticket, and most importantly, provide a reproducible example. A complete test, preferably using a fork of https://app.circleci.com/pipelines/github/cypress-io/cypress-test-tiny will help us help you.