Files
playwrong/.cursor/rules/projectinfo.mdc

77 lines
2.9 KiB
Plaintext

---
alwaysApply: true
---
# About This Project
This project is both USING and IMPLEMENTING the PlayWrong test language. It provides:
- A custom test language parser (`src/parser.js`)
- A test executor using Playwright (`src/executor.js`)
- A CLI interface (`src/cli.js`)
- Test files written in the custom syntax (`.test` files)
# PlayWrong Test Language - Cheat Sheet
## Dump Functionality
The `dump` command creates HTML snapshots in `test-results/Chrome/<dumpname>/` that can be searched for HTML elements to help develop test flows. These dumps are invaluable for:
- Inspecting page structure at specific test steps
- Finding correct element selectors
- Debugging test failures
- Understanding page state during test execution
## Commands
### Browser Control
- `use "Chrome"` - Select browser profile (Chrome, Mobile, MobileSmall, Firefox, Safari, Edge)
- `use "Chrome" ( "Mobile" , "MobileSmall")` - Multi-profile test
- `open "https://example.com"` - Navigate to URL
### Element Interaction
- `wait element=button childText="Login"` - Wait for element to appear
- `click element=button childText="Login"` - Click element
- `scroll element=div class="content"` - Scroll to element
- `fill element=input name="email" value="user@example.com"` - Fill input field
### Flow Control
- `sleep 1000` - Wait milliseconds
- `sleep 1000 "loading animation"` - Wait with description
- `break` - Pause execution (press any key to continue)
- `break "waiting for user input"` - Pause with message
- `dump "step_name"` - Take screenshot
- `jumpIf element=span childText="Server-Warenkorb" jump=4` - Jump over 4 commands if element exists
- `jumpIfNot element=span childText="Server-Warenkorb" jump=4` - Jump over 4 commands if element doesn't exist
### Element Selectors
- `element=tagname` - HTML tag (div, span, button, input, a, form, etc.)
- `name="fieldName"` - Name attribute
- `id="elementId"` - ID attribute
- `class="className"` - CSS class
- `href="/path"` - Link href
- `type="email"` - Input type
- `childText="Button Text"` - Element containing text
- `child=span(class="badge" childText="1")` - Nested element selector
### Variables & Comments
- `$VARIABLE` - Environment variable (e.g., `$PASSWORD`, `$PASSWORDMAIL`)
- `/* multi-line comment */` - Block comment
- `# single line comment` - Line comment
- `// alternative line comment` - Alternative line comment
### Example Complete Flow
```test
use "Chrome"
open "https://example.com"
wait element=input type="email"
fill element=input type="email" value="user@example.com"
wait element=input type="password"
fill element=input type="password" value="$PASSWORD"
click element=button childText="Login"
sleep 2000 "login processing"
dump "logged_in"
```
## Tips
- Use descriptive names in sleep messages for better debugging
- Always wait for elements before interacting with them
- Use environment variables for sensitive data like passwords
- Take screenshots (dump) at key steps for debugging
- Comments help document complex test flows