How to upload a file without having input tag and No file type and submit attribute

24 Views Asked by At

I have to click 1 icon and that is immediately opening an windows popup and no input tag is present and also no type= file and submit attributes,Is there any way in testcafe to upload this without having input tag

1

There are 1 best solutions below

0
Ahmad Salh On

you can use the testcafe library

import { Selector } from 'testcafe';

const fileInput = Selector('body');  // Use a selector for the entire document

// Click the icon to trigger the file upload dialog
// Set the file path using setFilesToUpload on the document
await t
  .click(iconSelector)
  .setFilesToUpload(fileInput, ['/path/to/your/file.txt'])
  .click(submitButton);  // If there is a submit button, click it