Upload multiple files | Playwright (Java) - Part 16

preview_player
Показать описание

Source code:
---------------------------------------------------------------------
Tamil Youtube Channel:
@kurimurai
---------------------------------------------------------------------
🎁Just in case you want to support me ☺️ donation might be helpful.

--------------------------Thank you---------------------------

Thanks for watching, if you like the video, give it a thumbs up 👆.
Sharing is caring, kindly share the video with your friends and colleagues.
Don't forget to subscribe and hit the bell 🔔 notification.

--------------------------------SOCIAL--------------------------------

Join our WhatsApp group (Only for Channel Members)

#letcode #playwright
Рекомендации по теме
Комментарии
Автор

Hey koushik, so when uploading file, if the type is button instead input how can i write it in java as it is bit complicated can you tell me the way that i can do it

BiseniPerera
Автор

Total how many chapters are there in Playwright series bro??

NRNov
Автор

Hi Koushik, I have added the files and created an object for each type of files as following:
const allTestFiles = {
excel: {
fileLocation: 'data/documents/test-files/Excel.xlsx',
fileName: 'Excel.xlsx'
},
jpeg: {
fileLocation: 'data/documents/test-files/JPEG.jpeg',
fileName: 'JPEG.jpeg'
},
pdf: {
fileLocation: 'data/documents/test-files/PDF.pdf',
fileName: 'PDF.pdf'
},
png: {
fileLocation: 'data/documents/test-files/PNG.png',
fileName: 'PNG.png'
},
text: {
fileLocation: 'data/documents/test-files/Text.txt',
fileName: 'Text.txt'
},
word: {
fileLocation: 'data/documents/test-files/Word.docx',
fileName: 'Word.docx'
},
zip: {
fileLocation: 'data/documents/test-files/ZIP.zip',
fileName: 'ZIP.zip'
},
deleteMeAfterUpload: {
fileLocation: 'data/documents/test-files/Delete-Me-After-Upload.txt',
fileName: 'Delete-Me-After-Upload.txt'
},
};

I am trying to create a a utilities method called uploadFile(locator, ...filePath) which supports single/multiple files uploads. Such as:
1. await util.controls.uploadFile(pageObjects.inRequestDocuments.browseForFile, data.allTestFiles);
2. await util.controls.uploadFile(pageObjects.inRequestDocuments.browseForFile, data.allTestFiles.excel);
3. await util.controls.uploadFile(pageObjects.inRequestDocuments.browseForFile,
4. await util.controls.uploadFile(pageObjects.inRequestDocuments.browseForFile, 'data/documents/all-test-files/Excel.xlsx''data/documents/all-test-files/PDF.xlsx',
5. await util.controls.uploadFile(pageObjects.inRequestDocuments.browseForFile, data.allTestFiles.excel, data.allTestFiles.pdf, data.allTestFiles.jpeg);

I am able to work with the scenarios 2, 3, 4, 5 but not scenario 1..

Could you please help?

MrHbb