Introduction
ZK Webdriver
ZK Webdriver is a powerful testing utility library designed specifically for ZK applications. Built on top of the industry-standard Selenium WebDriver, it provides a high-level API that simplifies testing ZK applications by abstracting away the complexities of AJAX and ZK component internals.
Why ZK Webdriver?
While Selenium is a great tool for general web testing, it often requires manual handling of AJAX requests and complex CSS selectors to interact with ZK’s rich UI components. ZK Webdriver addresses these challenges by providing:
- AJAX Awareness: Built-in mechanisms like
waitResponse()that automatically synchronize with ZK’s server-side processing. - ZK Component Integration: Easy access to ZK’s client-side widget objects and their properties.
- Simplified Locators: Powerful selector syntax (using
jq,zk) to find elements based on ZK-specific attributes and component types. - Standard Selenium Power: Since it’s built on Selenium, you still have full access to all Selenium WebDriver features.
Relationship with Selenium
ZK Webdriver is not a replacement for Selenium; rather, it is a wrapper and extension of Selenium WebDriver.
+-----------------------------------+
| Your Test Code |
+-----------------------------------+
|
v
+-----------------------------------+
| ZK Webdriver | <-- AJAX synchronization, ZK Widget API
+-----------------------------------+
|
v
+-----------------------------------+
| Selenium WebDriver | <-- Browser control, standard interactions
+-----------------------------------+
|
v
+-----------------------------------+
| Web Browser |
+-----------------------------------+
Suitable Scenarios
ZK Webdriver is ideal for:
- End-to-End (E2E) Testing: Verifying critical user flows across multiple pages and interactions.
- Browser Compatibility: Testing browser-specific behaviors and rendering.
- Integration Testing: Validating the full stack, including database interactions and server-side logic in a real browser environment.
Limitations and Trade-offs
Compared to ZATS (ZK Automated Testing Suite), ZK Webdriver has some trade-offs:
- Performance: It is slower than ZATS because it requires starting a real web server (e.g., Jetty) and a real browser (headless or UI).
- Complexity: Requires more setup (driver management, server configuration) compared to ZATS’s mock environment.
Recommendation: Use ZATS for fast, isolated unit/component testing. Use ZK Webdriver for final verification of critical paths and browser-specific features.