question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG] File not uploaded via the setInputFiles() function

See original GitHub issue

Context:

  • Playwright Version: 1.16.3
  • Operating System: Windows
  • Node.js version: 14.6
  • Browser: Chrome
  • Extra: [any specific details about your environment]

Code Snippet

Help us help you! Put down a short code snippet that illustrates your bug and that we can run and debug locally. For example:

await this.page.setInputFiles(this.fileNameTextFieldLocator, resourceFileToUpload);

Describe the bug

I’m trying to upload the file via page.setInputFiles() function. The locator is the following: image

It is an input element. But the function doesn’t work for me.

P.S. Maybe it is related to the fact that the input field is defined as a readonly?

P.S.2 The icon is not defined as input - can it be used in some way in the function? According to documentation - the function setInputFiles() can be used only with input elements.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:10 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
vsravuricommented, Nov 25, 2021

Your input should be of type=“file”, it should be somewhere in the DOM. This is how it’s in my application.

Screen Shot 2021-11-25 at 2 53 42 PM Screen Shot 2021-11-25 at 2 53 59 PM
0reactions
AlexKomanovcommented, Nov 29, 2021

@pavelfeldman It’s just a selector that founded in the DOM. We use the pattern: textFieldLocator - just stores a selector in the DOM. textFieldElement - element it self (of any type).

Read more comments on GitHub >

github_iconTop Results From Across the Web

Playwright: Upload files from non-input element that cannot be ...
To upload a file using Playwright use setInputFiles(selector, files[, options]) function. This method takes the selector of the input ...
Read more >
How to Upload File in Playwright - YouTube
In Playwright, you can use the setInputFiles() method to upload files, if the element type is input. For non-input element types or when...
Read more >
Using files from web applications - Web APIs - MDN Web Docs
The FileUpload function accepts two inputs: an image element and a file from which to read the image data. ... The FileUpload() function...
Read more >
MBS FileMaker Plugin: CURL.SetInputFile
SetOptionUpload to make it an upload for FTP/SFTP. Using this function is not recommended for more than a 1 GB of data. If...
Read more >
How to Upload File in Playwright - ProgramsBuzz
In Playwright, you can use the setInputFiles() method to upload files, if the element ... Multiple files are specified using the array[].
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found