Skip to content

Conversation

@DavertMik
Copy link
Contributor

@DavertMik DavertMik commented Dec 16, 2025

This PR adds support for using JSON strings as locators in CodeceptJS. When a string starts with { and ends with }, it will be parsed as JSON and transformed into a locator object.

Changes Made

  1. Enhanced Locator Class (lib/locator.js)
  • Added parsedJsonAsString() method to handle JSON string parsing
  • Supports simple key-value pairs as requested
  • Falls back gracefully to normal string processing for invalid JSON
  • Marks parsed locators as strict
  1. Comprehensive Test Coverage (test/unit/locator_test.js)
  • Added 12 test cases for JSON string parsing
  • Tests cover various locator types: CSS, XPath, ID, custom locators
  • Includes edge cases: whitespace, invalid JSON, aria-style locators
  • Verifies equivalence between object and JSON string formats

Usage Examples

  // These are now equivalent:
  I.seeElement({ css: '#button' })
  I.seeElement('{"css": "#button"}')

  // Aria-style locators 
  I.seeElement('{"role": "button", "text": "Save"}')

dependabot bot and others added 30 commits July 16, 2025 09:36
Bumps [playwright](https://github.com/microsoft/playwright) from 1.53.0 to 1.54.1.
- [Release notes](https://github.com/microsoft/playwright/releases)
- [Commits](microsoft/playwright@v1.53.0...v1.54.1)

---
updated-dependencies:
- dependency-name: playwright
  dependency-version: 1.54.1
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
---
updated-dependencies:
- dependency-name: "@eslint/js"
  dependency-version: 9.31.0
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Bumps [expect](https://github.com/jestjs/jest/tree/HEAD/packages/expect) from 29.7.0 to 30.0.4.
- [Release notes](https://github.com/jestjs/jest/releases)
- [Changelog](https://github.com/jestjs/jest/blob/main/CHANGELOG.md)
- [Commits](https://github.com/jestjs/jest/commits/v30.0.4/packages/expect)

---
updated-dependencies:
- dependency-name: expect
  dependency-version: 30.0.4
  dependency-type: direct:development
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Bumps [graphql](https://github.com/graphql/graphql-js) from 16.10.0 to 16.11.0.
- [Release notes](https://github.com/graphql/graphql-js/releases)
- [Commits](graphql/graphql-js@v16.10.0...v16.11.0)

---
updated-dependencies:
- dependency-name: graphql
  dependency-version: 16.11.0
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Bumps [electron](https://github.com/electron/electron) from 37.1.0 to 37.2.3.
- [Release notes](https://github.com/electron/electron/releases)
- [Changelog](https://github.com/electron/electron/blob/main/docs/breaking-changes.md)
- [Commits](electron/electron@v37.1.0...v37.2.3)

---
updated-dependencies:
- dependency-name: electron
  dependency-version: 37.2.3
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Bumps [axios](https://github.com/axios/axios) from 1.8.4 to 1.11.0.
- [Release notes](https://github.com/axios/axios/releases)
- [Changelog](https://github.com/axios/axios/blob/v1.x/CHANGELOG.md)
- [Commits](axios/axios@v1.8.4...v1.11.0)

---
updated-dependencies:
- dependency-name: axios
  dependency-version: 1.11.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
)

Bumps [typedoc-plugin-markdown](https://github.com/typedoc2md/typedoc-plugin-markdown/tree/HEAD/packages/typedoc-plugin-markdown) from 4.7.0 to 4.7.1.
- [Release notes](https://github.com/typedoc2md/typedoc-plugin-markdown/releases)
- [Changelog](https://github.com/typedoc2md/typedoc-plugin-markdown/blob/main/packages/typedoc-plugin-markdown/CHANGELOG.md)
- [Commits](https://github.com/typedoc2md/typedoc-plugin-markdown/commits/[email protected]/packages/typedoc-plugin-markdown)

---
updated-dependencies:
- dependency-name: typedoc-plugin-markdown
  dependency-version: 4.7.1
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Bumps [browser-actions/setup-chrome](https://github.com/browser-actions/setup-chrome) from 1 to 2.
- [Release notes](https://github.com/browser-actions/setup-chrome/releases)
- [Changelog](https://github.com/browser-actions/setup-chrome/blob/master/CHANGELOG.md)
- [Commits](browser-actions/setup-chrome@v1...v2)

---
updated-dependencies:
- dependency-name: browser-actions/setup-chrome
  dependency-version: '2'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Bumps [typedoc](https://github.com/TypeStrong/TypeDoc) from 0.28.7 to 0.28.10.
- [Release notes](https://github.com/TypeStrong/TypeDoc/releases)
- [Changelog](https://github.com/TypeStrong/typedoc/blob/master/CHANGELOG.md)
- [Commits](TypeStrong/typedoc@v0.28.7...v0.28.10)

---
updated-dependencies:
- dependency-name: typedoc
  dependency-version: 0.28.10
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
* fix: hook exit code

* Update asyncWrapper.js

Co-authored-by: Copilot <[email protected]>

* Update asyncWrapper.js

Co-authored-by: Copilot <[email protected]>

* Update asyncWrapper.js

Co-authored-by: Copilot <[email protected]>

* Update asyncWrapper.js

Co-authored-by: Copilot <[email protected]>

* Update asyncWrapper.js

* Update asyncWrapper.js

Co-authored-by: Copilot <[email protected]>

---------

Co-authored-by: Copilot <[email protected]>
Bumps [actions/checkout](https://github.com/actions/checkout) from 4 to 5.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](actions/checkout@v4...v5)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-version: '5'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Bumps [tsd](https://github.com/tsdjs/tsd) from 0.32.0 to 0.33.0.
- [Release notes](https://github.com/tsdjs/tsd/releases)
- [Commits](tsdjs/tsd@v0.32.0...v0.33.0)

---
updated-dependencies:
- dependency-name: tsd
  dependency-version: 0.33.0
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
)

Bumps [typedoc-plugin-markdown](https://github.com/typedoc2md/typedoc-plugin-markdown/tree/HEAD/packages/typedoc-plugin-markdown) from 4.7.1 to 4.8.1.
- [Release notes](https://github.com/typedoc2md/typedoc-plugin-markdown/releases)
- [Changelog](https://github.com/typedoc2md/typedoc-plugin-markdown/blob/main/packages/typedoc-plugin-markdown/CHANGELOG.md)
- [Commits](https://github.com/typedoc2md/typedoc-plugin-markdown/commits/[email protected]/packages/typedoc-plugin-markdown)

---
updated-dependencies:
- dependency-name: typedoc-plugin-markdown
  dependency-version: 4.8.1
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
* release 3.7.4
…Timeout` value at the end of test suite (#5077)

* Initial plan

* Changes before error encountered

Co-authored-by: kobenguyent <[email protected]>

---------

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: kobenguyent <[email protected]>
* Initial plan

* Changes before error encountered

Co-authored-by: kobenguyent <[email protected]>

---------

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: kobenguyent <[email protected]>
#5082)

* Initial plan

* Fix JUnit XML test case name inconsistency in scenario retries

Co-authored-by: kobenguyent <[email protected]>

* Improve edge case handling for empty suite titles in cloned tests

Co-authored-by: kobenguyent <[email protected]>

---------

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: kobenguyent <[email protected]>
* fix: TestCafe_test.js

* Fix TestCafe form submission timeout with efficient polling mechanism (#5080)

* Initial plan

* Fix failed TestCafe tests by skipping doubleClick test

* Update testcafe.yml

* Update testcafe.yml

* Update TestCafe_test.js

* Update TestCafe_test.js

* Changes before error encountered

Co-authored-by: kobenguyent <[email protected]>

* Fix TestCafe form submission timeout in CI environments

* Improve TestCafe form submission timeout handling with polling mechanism

Co-authored-by: kobenguyent <[email protected]>

* Improve TestCafe form submission timeout with efficient polling mechanism

Co-authored-by: kobenguyent <[email protected]>

* Changes before error encountered

Co-authored-by: kobenguyent <[email protected]>

* Changes before error encountered

Co-authored-by: kobenguyent <[email protected]>

* Changes before error encountered

Co-authored-by: kobenguyent <[email protected]>

* Update testcafe.yml

* fix: Chrome popup causes problems with TestCafe

---------

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: kobenguyent <[email protected]>
Co-authored-by: kobenguyent <[email protected]>

---------

Co-authored-by: Copilot <[email protected]>
* Initial plan

* Changes before error encountered

Co-authored-by: kobenguyent <[email protected]>

* Add TypeScript types for Feature.only method

* Changes before error encountered

Co-authored-by: kobenguyent <[email protected]>

* Fix TypeScript test expectations for hook return types

Co-authored-by: kobenguyent <[email protected]>

---------

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: kobenguyent <[email protected]>
* Initial plan

* Changes before error encountered

Co-authored-by: kobenguyent <[email protected]>

* Changes before error encountered

Co-authored-by: kobenguyent <[email protected]>

---------

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: kobenguyent <[email protected]>
kobenguyent and others added 17 commits October 2, 2025 17:21
* address HTML reporter issues

* address HTML reporter issues

* fix UTs and lint issue
…ils: TypeError: Chaining cycle detected for promise Fixes #4844) (#5276)
* Fix: preserve global timeout with BeforeSuite hook

* test: clarify feature name for global timeout with BeforeSuite

* chore: remove unused plugins field from beforeSuiteTimeout config
…5211)

* Update reports.md: use "reporter" option instead of CLI

* typo

* add config-only variant as an alternative
…5301)

* Use own implementation of shuffle to remve lodash.shuffle dependency

* Cleanup code

* After review
* Update some outdated deprendencies

* Stay om 1.55.1 of playwright
* Initial plan

* Fix HTML reporter to handle nested arrays in system info

- Updated escapeHtml() to handle non-string inputs including arrays and nested arrays
- Arrays are flattened and joined with commas before HTML escaping
- Added documentation to generateSystemInfoHtml() for clarity
- Added comprehensive unit tests for escapeHtml functionality
- Verified fix handles the exact issue case: edgeInfo with nested array

Co-authored-by: kobenguyent <[email protected]>

* Improve escapeHtml with recursive array flattening and DRY tests

- Refactored escapeHtml to use recursive flattening for deeply nested arrays
- Removed duplicate helper functions from test file (DRY principle)
- All 15 unit tests pass successfully
- Verified deep nesting support (e.g., [['Level2', ['Level3']]])

Co-authored-by: kobenguyent <[email protected]>

* Add depth limit to recursive flattening for safety

- Added maxDepth parameter (default: 100) to prevent stack overflow
- Returns string representation if depth limit reached
- Maintains full functionality for normal use cases

---------

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: kobenguyent <[email protected]>
@incoming-th
Copy link

@DavertMik Will that conflict with shadow? https://codecept.io/shadow/#locating-shadow-dom-elements

I tested shadow and not sure if codecept still compatible with it, but your change may also have an impact or I am mistaken?

@DavertMik
Copy link
Contributor Author

Good question! THanks, let me check this!

…, and strict mode

- Add JSON string parsing for locators (e.g., '{"css": "#button"}')
- Add selectOption support for ARIA combobox/listbox roles
- Add strict mode option for Playwright that throws MultipleElementsFound error
- Add MultipleElementsFound error class with detailed element info
- Add tests for all new features

Co-Authored-By: Claude Opus 4.5 <[email protected]>
@DavertMik DavertMik force-pushed the feat/locator-json-as-string branch from 604a651 to 6adfb39 Compare January 21, 2026 04:48
DavertMik and others added 4 commits January 28, 2026 02:18
Resolved merge conflicts between 3.x (CommonJS) and 4.x (ESM migration).
Accepted 4.x versions for all files to preserve ESM conversion while
incorporating changes from 3.x release 3.7.6.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Resolved conflict in test/unit/plugin/htmlReporter_test.js by keeping ESM import.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
@DavertMik DavertMik force-pushed the feat/locator-json-as-string branch from f629d6f to 0002eac Compare January 29, 2026 00:06
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.