0

I want to upload a file using playwright, but as I'm using a wsl, I don't know where I should put the file, for sure not in the windows folder, but where? Cause I tried to put it in the mounted disk in ubunbtu, but it isn't editable, I'm using SetInputFiles().

In the image you can see the file manager that playwright opens, i cant find the node folder in the image.Image

Talha Tayyab
  • 8,111
  • 25
  • 27
  • 44
Niky
  • 27
  • 5

1 Answers1

0

You can keep the file in the project fiolder itself and give relative path for that file. Make one folder in project name it as 'TestData' and copy file in the folder. if file name is test.png then you can give path as give below.

let path = require('path');
let fileToUpload = '/testData/fileUpload/' + fileName;
let absolutePath = path.resolve(process.cwd() + fileToUpload);
await this.page.locator("input[type='file']").setInputFiles(absolutePath);
Ketan Pardeshi
  • 516
  • 1
  • 5
  • 8