Skip to content

feat: wrap elements in WebElement for unified API across helpers#5497

Open
DavertMik wants to merge 6 commits into4.xfrom
feat/WebElement-wrapper-for-els
Open

feat: wrap elements in WebElement for unified API across helpers#5497
DavertMik wants to merge 6 commits into4.xfrom
feat/WebElement-wrapper-for-els

Conversation

@DavertMik
Copy link
Copy Markdown
Contributor

Summary

  • Wrap all elements returned by _locate() in WebElement class before passing to user functions
  • Provides consistent API across all helpers (Playwright, WebDriver, Puppeteer)
  • Element-based tests are now portable between helpers

Changes

Code Changes

  • lib/els.js: Import WebElement and wrap elements in element(), eachElement(), expectElement(), expectAnyElement(), expectAllElements()

Tests

  • test/unit/els_test.js: Updated to work with WebElement instances

Documentation

  • docs/element-based-testing.md: New comprehensive guide covering:
    • Why and when to use element-based testing
    • CodeceptJS hybrid approach (mixing I.* with element-based)
    • Full WebElement API reference
    • Real-world examples
  • docs/els.md: Removed portability warning, added link to new guide, fixed examples

Test plan

  • Unit tests pass (15 passing in els_test.js)
  • Run acceptance tests with Playwright helper
  • Verify API consistency across helpers

🤖 Generated with Claude Code

DavertMik and others added 6 commits March 27, 2026 00:12
- Import and use WebElement wrapper in lib/els.js for all element functions
- Provides consistent API (getText, getAttribute, click, etc.) across Playwright, WebDriver, Puppeteer
- Update unit tests to work with WebElement instances
- Add comprehensive element-based testing guide (docs/element-based-testing.md)
- Update docs/els.md to remove portability warning and link to new guide

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Replace invalid assert greaterThan/lessThan with expect().to.be.above/below
- Add proper chai imports in examples that use assertions
- Use expect() style consistently throughout

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Move API reference from element-based-testing.md to els.md
- Keep element-based-testing.md as a user guide with examples
- Update els.md import syntax to use ES6 imports
- Add complete WebElement API reference to els.md

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- els.md now references WebElement.md for full API
- element-based-testing.md updated to reference both docs
- No content duplication, clearer documentation structure

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Add comprehensive acceptance tests for element(), eachElement(), expectElement(), expectAnyElement(), expectAllElements()
- Update WebElement class to handle Playwright Locator objects:
  - type() uses fill() for Locator objects
  - $() and $$() use locator() and elementHandle() methods for Locator objects
- Fix session_test.js import paths for ESM
- 30 acceptance tests + 15 unit tests passing

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
For Playwright Locator objects, getProperty('value') should use
inputValue() method instead of evaluate() to get the current value
of input elements after fill() is called.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant