Skip to content

uploadFile don´t work with selectors css #1332

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

Closed
fran0254 opened this issue Nov 9, 2017 · 7 comments
Closed

uploadFile don´t work with selectors css #1332

fran0254 opened this issue Nov 9, 2017 · 7 comments

Comments

@fran0254
Copy link

fran0254 commented Nov 9, 2017

My button does not have (input[type="file"]).

I understand that elementHandle.uploadFile only works with (input[type="file"]) and not with id and class selectors css ??

const uplo = await page.$(".btnAddPhoto");
await uplo.uploadFile('image.jpg');

Out:

(node:3584) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: Protocol error (DOM.setFileInputFiles): _**# Node is not a file input element undefined**_
(node:3584) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
@fran0254 fran0254 changed the title uploadFile don´t work uploadFile don´t work with selectors css Nov 9, 2017
@JoelEinbinder
Copy link
Contributor

How does your site receive images? As far as I know, files can only be uploaded to input elements with type="file".

@ebidel
Copy link
Contributor

ebidel commented Nov 10, 2017

@fran0254 can you post a larger code snippet with the url you're testing against. We need more info to be helpful!

You should be selecting the file input with page.$ instead of the button that activates the upload. If you're not using a input type=file on the page, is the button using xhr.send(blob) to send the file? In that case, it wouldn't be appropriate to use .uploadFile().

@fran0254
Copy link
Author

fran0254 commented Nov 13, 2017

how can you check does not exist input type="file".
Is there a possibility to upload my files using css selectors?

code of site:

<div class="insertadonCol">
    <div class="photoUploaderWrapper">
        <div id="dropArea">
            <form action="/images/upload-image-tmp.php"
                  method="post" class="dropzone" drop-zone="" id="photoUploader"
                  enctype="multipart/form-data"></form>
        </div>
    </div>
</div>

Code of site DOM

captura de pantalla de 2017-11-13 08 18 54

captura de pantalla de 2017-11-13 08 12 19

@ebidel
Copy link
Contributor

ebidel commented Nov 13, 2017

I don't see an input type="file" in your markup or code that handles a file upload in your example. But in theory, you could use puppeteer to "drop" a file onto the form and then use page.evaluate to call form.submit() or do something like https://github.com/GoogleChrome/puppeteer/blob/master/docs/api.md#class-elementhandle.

@fran0254
Copy link
Author

Should I use coordinates to drop the file in the box? Can you please put a small example? I do not know how I could do it ...

@JoelEinbinder
Copy link
Contributor

We currently don't have support for drop targets. Filed it as #1376

@aslushnikov
Copy link
Contributor

Closing in favor of #1376.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants