workshop-playwright-python
Installation
To set up the environment, details are provided in Playwright for Python > Installation. In this workshop, we provide a script to install the necessary dependencies.
git clone https://github.com/ks6088ts-labs/workshop-playwright-python.git
cd workshop-playwright-python
# Install the dependencies
make install-deps-dev
Fundamentals
To run some demos, please follow the instructions below.
# Run tests in verbose mode
make test-verbose
# Show traces
make show-trace
# Generate code
make codegen
Guides
Authentication
- Run an application server
docker compose up
- Run code generator and log in to the app manually.
make codegen
-
Update the generated codes for storing state via
context.storage_state()
method -
Run the updated script named as
save_context.py
uv run scripts/save_context.py
- Run the following command to access to the app without logging in.
uv run scripts/load_context.py
Microsoft Playwright Testing
Playwright MCP server
Locust
Custom apps
Credentials
Run the following command to set up the credentials for the application.
# Run the application
uv run streamlit run workshop_playwright_python/apps/streamlit_authentication.py
To login, type your credentials described in .streamlit/config.yaml and click the "Login" button. (e.g. jsmith:abc
, rbriggs:def
)
OpenID Connect
To run a frontend application with authentication, you can refer to the following links.
For example, you can use the following file .streamlit/secrets.toml to set up authentication with Microsoft Entra ID.
[auth]
redirect_uri = "http://localhost:8501/oauth2callback"
cookie_secret = "xxx"
[auth.microsoft]
client_id = "your-client-id"
client_secret = "your-client-secret"
server_metadata_url = "https://login.microsoftonline.com/consumers/v2.0/.well-known/openid-configuration"
Then, run the application using the following command:
# Run the application
uv run streamlit run workshop_playwright_python/apps/authentication.py