Perform following steps,
- Create folder playwright/.auth outside tests
- Create folder setup inside tests
- Create a test file inside setup folder "file_name.setup.ts"
- Read userID and password from a file
- Login and write the storage state in user.json file
- File directory will be "playwright/.auth/user.json"
- await page.context().storageState({path: above_dir_path_var})
- Create a project in playwright.config.ts
- { name: 'auth-setup', testMatch: 'ts_file_name_of_auth_setup' }
- Add dependency and storage state in working project(s)
- use: { ..., storageState: 'directory_of_user.json' }, dependencies: ['name_of_auth_project']
No comments:
Post a Comment