Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/builde7b0b/playwright
playwright examples, OAuth implementations etc.
https://github.com/builde7b0b/playwright
Last synced: 16 days ago
JSON representation
playwright examples, OAuth implementations etc.
- Host: GitHub
- URL: https://github.com/builde7b0b/playwright
- Owner: builde7b0b
- Created: 2024-06-27T08:25:13.000Z (8 months ago)
- Default Branch: main
- Last Pushed: 2024-06-27T08:34:46.000Z (8 months ago)
- Last Synced: 2024-11-23T13:15:40.294Z (3 months ago)
- Language: TypeScript
- Size: 1.95 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# PLAYWRIGHT E2E TESTING WITH Backstage
if your Backstage or any other application uses OAuth for authentication, you'll need to account for that in your playwright test.
There are a few approaches you can take to handle OAuth authentication in your Playwright tests:## Programmatic login (recommended):
Set up the authentication state before running your tests.
This is typically the fastest and most reliable method.UI login:
Simulate the user login process through the UI. This is slower but can be useful for end-to-end testing of the login flow itself.Mock authentication:
If possible, set up a test environment where authentication is bypassed or mocked.## Microsoft Azure Login Flow
Homepage: User lands on the homepage.
Sign-In Button: User clicks the "Sign In" button.
Pop-Up Window: A pop-up window opens with the URL login.microsoftonline.com/ and client ID, among other parameters.
Authentication: User enters credentials in the pop-up window.
Redirection: After successful sign-in, the user is redirected to the dashboard.## How to Get Started
### Running Tests
1. Run the auth test once to set up the auth state:
`npx playwright test -g "authenticate"`2. Run all tests:
`npx playwright test`### Best Practices
1. Use descriptive test names and comments.
2. Group related tests using test.describe().
3. Use page.waitForSelector() or expect().toBeVisible() to ensure elements are ready before interacting.
4. Implement proper error handling and logging.
5. Regularly update tests as the application evolves.
6. Use CI/CD pipelines to run tests automatically on code changes.## Troubleshooting
If tests fail due to authentication issues, delete the auth.json file and re-run the authentication test.
For timing issues, consider increasing timeouts or adding additional waits.
Check for changes in selectors or page structure if tests start failing unexpectedly.