Troubleshooting

Common issues and solutions for the Playwright Java Framework.

Installation Issues

Playwright Browsers Not Installing

Problem: Browsers fail to install or installation is incomplete.

Solution:

  • Ensure you have sufficient disk space (browsers require ~1GB)
  • Check your internet connection
  • Try installing with verbose output:
    mvn exec:java \
      -Dexec.mainClass="com.microsoft.playwright.CLI" \
      -Dexec.args="install --with-deps chromium"
  • On Linux, ensure system dependencies are installed:
    sudo apt-get install libnss3 libatk1.0-0 libdrm2 libxkbcommon0 \
      libxcomposite1 libxdamage1 libxfixes3 libxrandr2 libgbm1 \
      libasound2 libpango-1.0-0 libcairo2

Maven Dependencies Not Resolving

Problem: Maven cannot download dependencies.

Solution:

  • Check your internet connection
  • Verify Maven settings.xml configuration
  • Clear Maven cache:
    rm -rf ~/.m2/repository
  • Try updating Maven:
    mvn clean install -U

Test Execution Issues

Tests Fail with "Browser Not Found"

Problem: Tests fail because browsers are not installed.

Solution:

  • Reinstall Playwright browsers:
    mvn exec:java \
      -Dexec.mainClass="com.microsoft.playwright.CLI" \
      -Dexec.args="install --with-deps"
  • Verify browser installation:
    mvn exec:java \
      -Dexec.mainClass="com.microsoft.playwright.CLI" \
      -Dexec.args="install --help"

Environment Variables Not Working

Problem: Tests fail because environment variables are not set.

Solution:

  • Verify environment variables are set:
    echo $DOMTREE_USER
    echo $DOMTREE_PASS
    echo $DOMTREE_API_BASE
  • On Windows PowerShell, restart terminal after setting variables
  • Set variables in your IDE run configuration
  • Use Maven properties as an alternative:
    mvn test -DDOMTREE_USER=your-email -DDOMTREE_PASS=your-password

Tests Timeout or Hang

Problem: Tests hang indefinitely or timeout.

Solution:

  • Check for infinite loops in step definitions
  • Verify element selectors are correct
  • Increase timeout in Playwright configuration
  • Check for network issues
  • Run tests in headed mode to see what's happening:
    // In your test code
    page.setViewportSize(1920, 1080);
    // Or set headless: false in playwright.config

API Testing Issues

JSON Parsing Errors

Problem: Jackson fails to parse JSON responses.

Solution:

  • Verify JSON response is valid
  • Check for null values before accessing JSON nodes:
    if (json.has("field") && !json.get("field").isNull()) {
        String value = json.get("field").asText();
    }
  • Use try-catch blocks for JSON parsing
  • Log the raw response for debugging

HTTP Client Connection Errors

Problem: API requests fail with connection errors.

Solution:

  • Verify API base URL is correct
  • Check network connectivity
  • Verify SSL certificates (if using HTTPS)
  • Check firewall settings
  • Add timeout configuration:
    HttpClient client = HttpClient.newBuilder()
        .connectTimeout(Duration.ofSeconds(30))
        .build();

Cucumber Issues

Step Definitions Not Found

Problem: Cucumber cannot find step definitions.

Solution:

  • Ensure step definition classes are in the correct package
  • Verify step definition annotations match feature file steps
  • Check that step definition classes are in the test classpath
  • Use exact string matching in step definitions

Feature Files Not Executing

Problem: Feature files are not being picked up by Cucumber.

Solution:

  • Verify feature files are in src/test/resources/features/
  • Check file extensions are .feature
  • Verify Cucumber configuration in pom.xml
  • Run with explicit feature file path:
    mvn test -Dcucumber.features="src/test/resources/features/login.feature"

Reporting Issues

Reports Not Generated

Problem: Test reports are not created after test execution.

Solution:

  • Verify tests actually ran (check Maven output)
  • Check that target/cucumber-reports/ directory exists
  • Verify Cucumber reporting plugin is configured in pom.xml
  • Check file permissions on the target directory

Getting Help

If you're still experiencing issues:

  • Check the GitHub repository for known issues
  • Review test execution logs for detailed error messages
  • Run tests with verbose output:
    mvn test -X
  • Open an issue on GitHub with:
    • Error message and stack trace
    • Steps to reproduce
    • Java and Maven versions
    • Operating system information