Skip to content

Deterministic JavaScript Execution and Unified Exception Handling

Choose a tag to compare

@sbabcoc sbabcoc released this 19 Jan 20:10

🚀 Major Enhancements

JavaScript Execution Runtime

  • Introduced a robust JavaScript execution runtime (__wdRuntime) supporting:

    • Synchronous and asynchronous execution
    • Promise-aware completion handling
    • Deterministic result and error envelopes
    • Configurable timeout enforcement for async scripts
  • Replaced legacy glue-library injection with idempotent runtime injection

  • Added standardized execution templates (exec-sync.format, exec-async.format) for consistent behavior across browsers

Cross-Language Exception Propagation

  • Added a unified Java ⇄ JavaScript exception bridge

  • JavaScript can now explicitly fail with a requested Java exception type:

    __wd.fail("com.example.MyException", "message");
  • Java exceptions are instantiated reflectively and validated against policy


🧩 Exception Architecture Overhaul

New Exception Base and Types

  • Introduced SeleniumFoundationException, extending WebDriverException

  • Added:

    • ScriptExecutionException for script/runtime failures
    • JavaScriptStackTrace as a carrier for browser-side stack traces
  • Introduced an ExceptionPolicy SPI to control which exception types may be propagated

Behavioral Changes

  • JavaScript stack traces are now attached as suppressed exceptions when available
  • Framework exceptions integrate cleanly with Selenium’s reporting and retry mechanisms

⚠️ Potentially Breaking Change
Code that catches specific RuntimeException or WebDriverException subclasses may observe different exception types.


🧪 Shadow DOM & Browser Handling Improvements

  • Shadow host validation now fails via runtime-mediated exception propagation
  • Removed browser-specific exception suppression in favor of consistent runtime behavior
  • Tests explicitly skip unsupported environments rather than relying on error detection
  • Improved Safari and iOS Safari stability for Shadow DOM access

🔧 API & Utility Improvements

JavaScript Utilities

  • JsUtility refactored to:

    • Use the new runtime exclusively
    • Support configurable async timeouts
    • Remove deprecated injection paths

WebDriver Utilities

  • Added WebDriverUtils.getAutomationEngine(SearchContext)
  • Android activity launching now uses shared capability resolution logic
  • Improved page refresh stability by waiting for load completion after navigation

🧹 Internal Cleanup & Maintenance

  • Removed deprecated JavaScript glue libraries
  • Simplified exception propagation and handling paths
  • Updated documentation and examples to reflect version 32.0.1

📌 Summary

Version 32.0.1 introduces a modern, deterministic JavaScript execution and error-propagation model, unifies framework exception handling, and improves reliability across browsers—especially for Shadow DOM and async script execution.

Highly recommended for users relying on JavaScript execution, Shadow DOM interaction, or custom exception handling.