My FeedDiscussionsHeadless CMS
New
Sign in
Log inSign up
Learn more about Hashnode Headless CMSHashnode Headless CMS
Collaborate seamlessly with Hashnode Headless CMS for Enterprise.
Upgrade ✨Learn more

Cannot upload files with javascript code on webpage

Default profile photo
Anonymous
·Mar 3, 2020

The objective is to automize a process with Task Scheduler and to upload a file to a webpage. I have identified the part of the code where the process is failing. The javascript code l have is:

// We wait for the button "Send Invitations" appears on the webpage

await page.waitForSelector('input[name=commit]', {visible: true}); // Upload the archive DIAS_ATRASO

fileInput = await page.$('input[type="file"]'); await fileInput.uploadFile(archivoDiasAtraso);

// Wait 7 minutes for the archive to upload

await page.waitFor(420000);

Relevant const and vars:

var archivoDiasAtraso = filePath + 'XX_XX_XX_' + currentDate + '.zip'; const filePath = 'C:/Users/name/Documents/X/XX/';

The code in the browser is the following:

input multiple="multiple" type="file" name="upload[file][]" id="upload_file"

There is one other button on the same page which looks like the following:

input type="submit" name="commit" value="Send Invitations" class="btn btn-lg btn-primary"

I do not know what has changed and I cannot identify what exactly is the problem. If you need more information, please let me know. I hope someone can help me with this. Thank you!