lundi 22 février 2021

uploading files in testcafe isn't working

Can someone help me with uploading files in TestCafe? I have the following html (I have removed the classes for better readability:

<form id="__uploader0-fu_form" enctype="multipart/form-data" method="post" action="" target="__uploader0-frame" style="display: inline-block;">
    <div>
        <div class="sapUiFupGroup" style="border: 0; cellPadding: 0; cellSpacing: 0;">
            <div>
                <div style="display: none;">
                    <div id="__uploader0-fu_input">
                        <div id="__uploader0-fu_input-content">
                            <input id="__uploader0-fu_input-inner"></div>
                        </div>
                    </div>
                    <div>
                        <button id="__uploader0-fu_button">
                            <span id="__uploader0-fu_button-inner">
                                <span id="__uploader0-fu_button-img" role="presentation" aria-hidden="true"/>
                            </span>
                            <span id="__uploader0-fu_button-tooltip">Searching</span>
                        </button>
                    <span id="__uploader0-AccDescr" aria-hidden="true">Activate to select file</span>
                </div>
            </div>
        </div>
        <div>
            <input type="file" aria-hidden="true" name="__uploader0" id="__uploader0-fu" tabindex="-1" size="1" accept=".jpg,.jpeg,.pdf,.docx">
            <input type="hidden" name="_charset_" aria-hidden="true">
            <input id="__uploader0-fu_data" type="hidden" aria-hidden="true" name="__uploader0-data" value="">
        </div>
    </div>
</form>

I have tried:

await t.setFilesToUpload(Selector('#__uploader0-fu'), ['../data/a.pdf']);

And

await t.setFilesToUpload(Selector('input').withAttribute('type','file'), ['../data/a.pdf']);

But it's not working.

The upload button/form looks like this: screenshot upload

Aucun commentaire:

Enregistrer un commentaire