Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Unable to have drag and drop working#341

Unanswered
ptarczon asked this question inQ&A
Discussion options

I would like to useDrag-n-drop component

cy.get('[data-cy="dropzone"]').attachFile('myfixture.json', { subjectType: 'drag-n-drop' });

to test uploading a file by imitating drag and drop.

I wrote a simple test:

it('drag and drop a pdf file', () => {        cy.get('input[type="file"]')            .attachFile(pdfFilePath, {subjectType: 'drag-n-drop'});    })

WherepdfFilePath is the path to the pdf file and is declared like this:

const pdfFilePath = 'testFiles/pdf/Test_file.pdf'

And when running test it looks like it is executing the code:

imageedit_0_3315224730

But in the application I don't see any file attached on the UI

Do you know what may be the reason and how to approach this?

Btw to be able to do HTML5 file input without encoding problems with upload of pdf file I had to add encoding:

cy.get('input[type="file"]')        .attachFile({ filePath: pdfFilePath, encoding: 'base64'});
You must be logged in to vote

Replies: 1 comment

Comment options

When using drag-n-drop, check how the events are implemented in the website.
In my case I needed a "change" event. The normal drag, drop, etc events are not implemented at our side.
So it would become: cy.get('.upload__box').attachFile({filePath:'test_files/testDummy.pdf',encoding: "base64"},{subjectType:'drag-n-drop'}).trigger('change')

Note: Would need to check if I have time, but for drag and drop I thought it's looking for an 'input[types=""file'] in underlying elements. So I passed the element above as selector.

You must be logged in to vote
0 replies
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Category
Q&A
Labels
None yet
2 participants
@ptarczon@krisodb

[8]ページ先頭

©2009-2025 Movatter.jp