ddutra
ddutra

Reputation: 1509

How to manually trigger a upload file event on Dropzone

I have Dropzonejs nicely integrated into my frontend (VueJS).

I have problem with Acceptance Testing Dropzone using Webdriver / Codeception. Bottom line is Webdriver NEEDS a file input so it can attach files too.

<input id="file_upload" type="file" name="file"/>

Any way to manually trigger a upload inside the dropzone instance? I can put a button on the page and trigger the upload inside dropzone but keep its functionality. This input would only render when my frontend configuration is set to <> PRODUCTION.

enter image description here

Thanks in advance!

Edit:

I just found out Dropzonejs appends a hidden input (.dz-hidden-input) to the body by default or werever you want using de hiddenInputContainer option. That input is directly hooked into Dropzone, if you edit the source and make it not hidden and use it to pick files the queue process runs automatically. Thats what I need!

Problem is the input is Hidden and my test suite + selenium webdriver cannot interact with the input if its hidden. Any way to make it visible without altering default behavior?

Thanks!

Upvotes: 1

Views: 1987

Answers (2)

user7370131
user7370131

Reputation:

this works for me

put in your test

$I->attachFile('input.dz-hidden-input', 'your_file.txt');

Upvotes: 2

ddutra
ddutra

Reputation: 1509

Selenium can only work with file input via the $I->attachFile method. I dropped dropzonejs in favor of another solution (custom made) that implements a and its all good now!

Upvotes: 0

Related Questions