Files
pxil-selenium-automation/playwright_tests/README.md
T

4.7 KiB

Session and token setup with Playwright

This suite uses config.json (not config/runtime.json) and the existing setup locators. The setup URL is now https://utilseastern.pxil.in/Pxil/. This shared configuration also changes the URL used by Selenium setup on the migration branch.

Install

The separate .venv-playwright environment and Chromium are installed on this machine. For a fresh checkout, from the repository root in PowerShell:

python -m venv .venv-playwright
.\.venv-playwright\Scripts\python.exe -m pip install -r requirements-playwright.txt
.\.venv-playwright\Scripts\python.exe -m playwright install chromium

Run

All commands below open Chromium. Credentials are filled automatically. Enter the six-character CAPTCHA in the browser; Playwright then clicks Sign in automatically. If CAPTCHA length changes, set playwright.captcha_length in config.json. The default CAPTCHA timeout is 180 seconds; override with --captcha-timeout 300.

Login and logout only, without creating records:

.\.venv-playwright\Scripts\python.exe -u -m pytest -c playwright.ini --setup-flow login

Create a session only:

.\.venv-playwright\Scripts\python.exe -u -m pytest -c playwright.ini --setup-flow session

Create a token, edit ORDER_NOR / ORDER_EXCH / TRADE, and activate it for one product:

.\.venv-playwright\Scripts\python.exe -u -m pytest -c playwright.ini --setup-flow token --token-products IDAS

Create a session and then a token within the same login:

.\.venv-playwright\Scripts\python.exe -u -m pytest -c playwright.ini --setup-flow both --token-products IDAS

Follow the existing setup.run_session / setup.run_token flags and configured product list:

.\.venv-playwright\Scripts\python.exe -u -m pytest -c playwright.ini

Explicit --setup-flow overrides the setup flags. --token-products overrides the product list for that run without editing the configuration. Without that override, the current configuration selects seven products. A standalone token run assumes a valid trading session already exists. Combined setup runs session creation first.

If a token was saved before a later step failed, resume that exact token instead of creating it again (replace the product and token ID with the saved record):

.\.venv-playwright\Scripts\python.exe -u -m pytest -c playwright.ini --setup-flow token --token-products IDAS3 --resume-token-id 080926083528OXVH

Resume requires exactly one product and looks up the exact token ID in Time Session View. It skips Add New Token/save Token, edits the configured time sessions, and activates the existing token. The configuration names ORDER_NOR and ORDER_EXCH also match the application's ORDER_NORMAL and ORDER_EXCHANGE labels.

Schedule and outcome checks

Before browser startup, the suite validates the session window, token expiry, and each time-session start/end pair. Update the same fields used by Selenium in config.json when the day's schedule has expired. It does not silently move the schedule or replace existing records.

Token saves and time-session updates require a successful response from their specific server endpoint. Activation requires the application's 1| success message and the Save & Activate button to disappear. A null message is a failure, even if the response status is zero. Session creation uses success notifications/alerts. Visible errors and missing confirmations fail the test. A missing confirmation must be investigated using the trace before rerunning, because the server may already have saved the record. There are no automatic mutation retries.

Grid selection requires a unique matching button. It fails instead of silently selecting the first token if the application lists multiple records.

Reports and local checks

Each live run writes a unique folder under reports/playwright/, with an HTML report, embedded step screenshots, and failure artifacts/traces. These files are Git-ignored. The original Selenium suite does not collect these tests through its default config.

Run local schedule and browser-helper checks without contacting PXIL:

.\.venv-playwright\Scripts\python.exe -m pytest -c playwright.ini playwright_checks -o addopts= -p no:cacheprovider --browser chromium -q

Validated on 2026-09-08: live utilseastern login, automatic Sign in after manual CAPTCHA, dashboard detection, logout, new token creation, and all three time-session updates. Activation of token 080926084458LQSS returned a null message from updateTokenMstr; successful activation is not confirmed. Session creation still needs live validation. Selenium backup remains at backup/selenium-working-2026-09-08.