File tree Expand file tree Collapse file tree 2 files changed +28
-0
lines changed
Expand file tree Collapse file tree 2 files changed +28
-0
lines changed Original file line number Diff line number Diff line change 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+ } ) ;
You can’t perform that action at this time.
0 commit comments