Handling files in Playwright



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);
});
Tags:
Leave a comment

Your email address will not be published. Required fields are marked *

Subscribe now

Receive weekly newsletter with educational materials, new courses, most popular posts, popular books and much more!