Skip to content

Commit 3d366e5

Browse files
Added FileUpload.spec.js script and Sample file
1 parent 886d6ef commit 3d366e5

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
const { test, expect } = require('@playwright/test');
2+
3+
test('Verify File Upload', async ({ page }) => {
4+
5+
//Define Selectors
6+
const targetURL = 'https://qa-practice.netlify.app/file-upload';
7+
const fileUploadBtnSelector = '#file_upload';
8+
const confirmationMsgSelector = '#file_upload_response';
9+
const filePath = './tests/File Upload/solar_system.png';
10+
11+
// Navigate to the target URL
12+
await page.goto(targetURL);
13+
14+
// Upload the file
15+
await page.locator(fileUploadBtnSelector).setInputFiles(filePath);
16+
17+
// Wait to ensure the file is uploaded
18+
await page.waitForTimeout(1000);
19+
20+
// Click the submit button
21+
await page.getByRole('button', { name: 'Submit' }).click();
22+
23+
// Wait for the confirmation message to appear
24+
const confirmationMessage = await page.locator(confirmationMsgSelector).textContent();
25+
26+
// Assert the confirmation message contains the file name
27+
expect(confirmationMessage).toContain('solar_system.png');
28+
});

tests/File Upload/solar_system.png

92.6 KB
Loading

0 commit comments

Comments
 (0)