Assertions
Drama Finder provides assertion methods that leverage Playwright’s auto-retry mechanism to handle asynchronous state changes in Vaadin applications. These assertions automatically wait for conditions to be met, eliminating flaky tests caused by timing issues.Auto-Retry Assertions
Playwright assertions automatically retry until the condition is met or a timeout occurs (default 5 seconds). This is essential for testing Vaadin’s asynchronous UI updates.Why Auto-Retry Matters
Built-in Assertion Methods
Drama Finder element classes provide assertion methods that wrap Playwright assertions with semantic names.Visibility Assertions
State Assertions
Value Assertions
Component-Specific Assertions
Assertion Symmetry Pattern
For each state getter, Drama Finder provides matching assertion methods:Null Handling in Assertions
Assertion methods handlenull values to test the absence of attributes:
Usage Example
Attribute vs Property Assertions
HTML Attributes
UsehasAttribute() for HTML attributes:
DOM Properties
UsehasJSProperty() for JavaScript properties:
When to Use Which
Testing Validation States
Component-Level Assertions
Theme and Style
ARIA and Accessibility
Prefix and Suffix Content
Grid Assertions
Grid elements have specialized assertions for tabular data:Combining Multiple Assertions
Timeout Configuration
Adjust timeout for specific assertions when needed:Best Practices
Always use auto-retry assertions
Always use auto-retry assertions
Use Playwright assertions (
assertThat()) or element assertion methods instead of raw boolean checks:Test async state changes
Test async state changes
After actions that trigger async updates, use assertions that wait:
Use semantic assertion methods
Use semantic assertion methods
Prefer element-specific assertion methods over generic Playwright assertions:
Handle null in custom assertions
Handle null in custom assertions
When writing custom assertion helpers, always handle null to test attribute absence:
Common Pitfalls
Related Concepts
- Element Lookup - Find elements using factory methods
- Locator Patterns - Understand locator delegation
- ARIA Roles - Accessibility-first testing