Skip to main content

Overview

This guide addresses common issues you may encounter when writing tests with Drama Finder, organized by category with practical solutions.

Locator Issues

Element Not Found

Symptoms:
  • Error: Element not found
  • PlaywrightException: Timeout 15000ms exceeded
  • Locator returns null or empty
Common Causes:
  1. Incorrect Label or Text
  2. Element Not Yet Rendered
  3. Shadow DOM Not Pierced
Solution:
  • Verify the exact label/text in your application
  • Ensure Vaadin Flow is ready before interactions
  • Use CSS selectors, not XPath, for shadow DOM elements
  • Check element visibility with assertVisible() first

Multiple Elements Matched

Symptoms:
  • Error: Multiple elements found
  • Wrong element is selected
  • Ambiguous locator warning
Common Causes:
  1. Missing .first() Call
  2. Not Using Scoped Lookup
Solution:
  • Always use .first() when creating elements from broad selectors
  • Use scoped lookups within containers
  • Use more specific factory methods (getByLabel, getByText)
  • Add unique labels or aria-labels to distinguish similar elements

Wrong Locator Type

Symptoms:
  • getAttribute() returns unexpected results
  • Actions don’t work (click, fill, etc.)
  • State checks fail
Common Causes:
  1. Component vs. Input Locator Confusion
  2. Focus Locator Mismatch
Solution:
  • Use getInputLocator() for: value, maxlength, pattern, placeholder
  • Use getLocator() for: theme, class, opened, component-level attributes
  • Use getEnabledLocator() and getFocusLocator() for state checks
  • Consult element documentation for which locator to use

Timing and Synchronization Issues

Flaky Tests Due to Timing

Symptoms:
  • Tests fail intermittently
  • “Element not visible” errors
  • State assertions fail randomly
Common Causes:
  1. Not Using Auto-Retry Assertions
  2. Hard Waits Instead of Smart Waits
  3. Not Waiting for Vaadin Flow
Solution:
  • Use Playwright assertions that auto-retry
  • Avoid Thread.sleep() and page.waitForTimeout()
  • Use element-specific assertion methods
  • Ensure WAIT_FOR_VAADIN_SCRIPT runs after navigation
  • Increase default timeouts if necessary

Actions Not Taking Effect

Symptoms:
  • click() does nothing
  • setValue() doesn’t change value
  • Form submission fails
Common Causes:
  1. Element Not Actionable
  2. Missing Event Dispatch
  3. Wrong Element Clicked
Solution:
  • Verify element is visible, enabled, and stable before actions
  • Use element-specific action methods (setValue, check, selectItem)
  • Dispatch events after programmatic changes
  • Check for overlays or loading indicators covering elements

Assertion Failures

Unexpected Attribute Values

Symptoms:
  • Expected attribute not present
  • Attribute has different value than expected
  • null when expecting a value
Common Causes:
  1. Attribute vs. Property Confusion
  2. Boolean Attributes
  3. Null Handling
Solution:
  • Use lowercase attribute names
  • Boolean attributes: check for empty string or absence
  • Handle null values in assertion helpers
  • Use hasJSProperty for DOM properties

State Check Failures

Symptoms:
  • assertEnabled() fails when element appears enabled
  • assertChecked() fails for checked checkbox
  • Focus assertions fail
Common Causes:
  1. Checking Wrong Element
  2. Invalid State Not Triggered
  3. Async State Change
Solution:
  • Use correct locator for state checks (component vs. input)
  • Trigger validation before checking invalid state
  • Use assertions that auto-retry
  • Check element documentation for state location

Setup and Configuration Issues

Browser Launch Failures

Symptoms:
  • Error: Executable doesn't exist
  • Browser crashes on startup
  • Headless mode issues
Common Causes:
  1. Playwright Browsers Not Installed
  2. Missing Dependencies (Linux)
  3. Permissions Issues
Solution:
  • Install Playwright browsers before running tests
  • Install system dependencies on Linux
  • Check file permissions
  • Use Docker with pre-installed browsers for CI

Port and Network Issues

Symptoms:
  • Connection refused errors
  • Tests can’t navigate to URL
  • Blank pages
Common Causes:
  1. Port Not Available
  2. Server Not Started
  3. Wrong URL
Solution:
  • Use RANDOM_PORT in Spring Boot tests
  • Inject @LocalServerPort for dynamic port
  • Verify application starts successfully
  • Check for port conflicts

Vaadin-Specific Issues

Symptoms:
  • White screen
  • JavaScript errors
  • Components not rendering
  • WAIT_FOR_VAADIN_SCRIPT times out
Common Causes:
  1. Dev Mode Bundle Not Built
  2. Node Modules Missing
  3. Frontend Resources Not Served
  4. JavaScript Errors
Solution:
  • Build frontend before running tests
  • Check for JavaScript errors in console
  • Verify Vaadin resources are accessible
  • Use production mode for faster tests (if applicable)
  • Check network tab for failed resource loads

Performance Issues

Slow Test Execution

Symptoms:
  • Individual tests take > 10 seconds
  • Test suite takes very long
  • Frequent timeouts
Common Causes:
  1. Long Default Timeouts
  2. Not Using Production Mode
  3. Redundant Navigation
  4. Not Running in Parallel
Solution:
  • Use production mode for tests when possible
  • Enable parallel test execution
  • Reduce timeouts if tests don’t need long waits
  • Avoid redundant navigation
  • Profile tests to find bottlenecks

ARIA Role Issues

Wrong ARIA Role in Lookups

Symptoms:
  • getByLabel can’t find element
  • Factory methods return null
  • Multiple elements matched unexpectedly
Common Causes:
  1. Wrong ARIA Role for Component
  2. Component Type Mismatch
Reference: Common ARIA Roles
  • Text inputs: TEXTBOX
  • Number inputs: SPINBUTTON
  • Date/time pickers: COMBOBOX
  • Buttons: BUTTON
  • Checkboxes: CHECKBOX
  • Radio buttons: RADIO
  • ComboBox/Select: COMBOBOX
  • Links: LINK
Solution:
  • Use correct element type for component
  • Check actual ARIA role in browser DevTools
  • Refer to Vaadin documentation for component roles
  • Use Drama Finder factory methods (they use correct roles)

Debugging Tips

Enable Visual Debugging

Console Logging

Screenshots on Failure

Slow Motion

Trace Recording

Getting Help

Check Documentation

Element Reference

Detailed API documentation

Best Practices

Writing maintainable tests

Common Patterns

Real-world examples

Setup Guide

Initial configuration

Community Resources

  • Drama Finder GitHub: Report issues and request features
  • Playwright Documentation: Official Playwright Java docs
  • Vaadin Documentation: Component behavior and attributes
  • Stack Overflow: Tag questions with playwright, vaadin, and drama-finder

Creating Bug Reports

When reporting issues, include:
  1. Minimal reproducible example
  2. Environment details
    • Java version
    • Playwright version
    • Vaadin version
    • Drama Finder version
    • OS and browser
  3. Error messages and stack traces
  4. Screenshots or videos if applicable
  5. Expected vs. actual behavior