Repository navigation
Remove duplicated code from shared, core, backend and conformance - #521
Merged
Merged
Conversation
This was referenced Oct 30, 2026
A duplicate-block scan found code repeated within and across the library packages. Each true duplicate now lives once, in the package the import rules allow: - The accessibility tree and elements page scripts each defined getAccessibleName's explicit-name steps; they share the source as EXPLICIT_NAME_SCRIPT, as they already share IS_VISIBLE_SCRIPT, since each script runs in the page on its own and cannot share a function. - automationName's UiAutomator check appeared five times in core's locator code; it is now isUiAutomatorDriver. - The backend and Nightwatch each listed the Nightwatch config file names; the list, with the WDIO one beside it, is now in shared. - Two conformance allowlist entries repeated the same six rules for the same root cause; they share SCRIPT_INJECTION_RULES. Kept: elements' locators index names core's exports one by one on purpose, as the gate on that published package's API, and the backend and Nightwatch each keep their own config-file search, which start from different places. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
vishnuv688
force-pushed
the
refactor/app-style-duplicates
branch
from
October 30, 2026 10:13
1176e67 to
d22a316
Compare
vishnuv688
force-pushed
the
refactor/library-duplicates
branch
from
October 30, 2026 10:13
aea93af to
7aa154b
Compare
vishnuv688
changed the base branch from
refactor/app-style-duplicates
to
main
November 2, 2026 10:12
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What & why
Part of #528 and #494. Stacked on #520.
A duplicate-block scan found code repeated within and across the library packages. Each true duplicate now lives once, in the package the import rules allow; lookalikes with different purposes stay, with the reason below. No behaviour change.
Type of change
Packages touched
shared(types and contracts)core(framework-agnostic capture/reporting)elements(published element/snapshot API —@wdio/elements)service(WebdriverIO adapter)nightwatch-devtools(Nightwatch adapter)selenium-devtools(Selenium adapter)selenium-devtools-py(Selenium Python adapter)backend(server)app(UI)script(page-injected runtime)trace(Trace mode)Plus
conformance, which the list does not include.Capability matrix
packages/conformance/src/features.tsupdated, and tables regenerated withpnpm docs:capabilities, if this adds or changes user-facing behaviourNot needed: no behaviour change.
Notes for reviewers
shared/element-scripts.ts: the accessibility-tree and elements page scripts each definedgetAccessibleName's explicit-name stepsEXPLICIT_NAME_SCRIPT, the way they already shareIS_VISIBLE_SCRIPT: each script is serialized and runs in the page on its own, so they cannot share a function. Each keeps its own fallbackscore/locators:automationName…includes('uiautomator'), five times across two filesisUiAutomatorDriver, not added to the locators index, so@wdio/elements' API is unchangedNIGHTWATCH_CONFIG_FILENAMESand NightwatchCONFIG_FILENAMESshared/runner.tswithWDIO_CONFIG_FILENAMES; the backend's now-emptytypes.tsre-export is deletedconformance/allowlist.ts: two entries listing the same six rules for one root causeSCRIPT_INJECTION_RULES; each entry keeps its own reasoncore/locators/index.tsvselements/locators/index.tsexport *would publish every future core exportsharedhas no Node I/OScan for these packages: 6 blocks before, 3 after (the 3 kept above).
Why this touches an adapter: only to delete Nightwatch's copy of the config file list in favour of shared's; no adapter logic changes.
Testing
pnpm install --frozen-lockfile,pnpm build,pnpm test(3428 passed) andpnpm lintare green; no workspace import leaks in the elements, backend, service, Selenium or Nightwatch bundles.isUiAutomatorDriveracross drivers and case, and the Android vs iOS branch ofgetSuggestedLocators; the config file name lists.@wdio/elements'.d.tsfiles are byte-identical to before, and its export list is unchanged.Screenshots / recordings
Not applicable: no UI change.
🤖 Generated with Claude Code