-
Notifications
You must be signed in to change notification settings - Fork 59
Expand file tree
/
Copy pathdebug-upload.mjs
More file actions
25 lines (21 loc) · 914 Bytes
/
Copy pathdebug-upload.mjs
File metadata and controls
25 lines (21 loc) · 914 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import { chromium } from 'playwright';
const imgPath = 'C:/Users/Dell/AppData/Local/Temp/upload-test.jpg';
const browser = await chromium.launch({ headless: true });
const page = await browser.newPage();
page.on('response', async (res) => {
if (res.url().includes('/api/products') && res.request().method() === 'POST') {
const status = res.status();
const text = await res.text().catch(() => 'unreadable');
console.log('Status:', status);
console.log('Body:', text);
}
});
await page.goto('http://localhost:5174/create');
await page.waitForLoadState('networkidle');
await page.fill('input[placeholder="Product Name"]', 'Debug Product');
await page.fill('input[type="number"]', '50');
await page.locator('input[type="file"]').setInputFiles(imgPath);
await page.waitForTimeout(1500);
await page.click('button:has-text("Add Product")');
await page.waitForTimeout(5000);
await browser.close();