- Jul 06, 2026
- admin
- 0
Handling files in Playwright
import {test, Page, Locator, expect,FileChooser } from ‘@playwright/test’;
//uploading single file
test(‘Upload single file’,async({page})=>
{
await page.goto(“https://www.file.io/”);
let uploadIcon:Locator=await page.locator(“//label[@for=’select-files-input’]”);
await uploadIcon.setInputFiles(‘C:/Users/AnandaBabuGummadilli/Documents/Anand_Details/VEDL_Info.docx’);
await page.waitForTimeout(5000);
});
//Uploading multiple files
test(‘Upload multiple files’,async({page})=>
{
await page.goto(“https://www.file.io/”);
let uploadIcon:Locator=await page.locator(“//label[@for=’select-files-input’]”);
await uploadIcon.setInputFiles([‘C:/Users/AnandaBabuGummadilli/Documents/Anand_Details/VEDL_Info.docx’, ‘C:/Users/AnandaBabuGummadilli/Documents/Anand_Details/Hindalco.docx’]);
await page.waitForTimeout(5000);
});
