fix(webdriverio): escape quotes in selectByAttribute values by ML642 · Pull Request #16157 · webdriverio/webdriverio · GitHub
Skip to content

fix(webdriverio): escape quotes in selectByAttribute values - #16157

Open
ML642 wants to merge 1 commit into
webdriverio:mainfrom
ML642:fix/select-by-attribute-quotes
Open

ML642 wants to merge 1 commit into
webdriverio:mainfrom
ML642:fix/select-by-attribute-quotes

Conversation

@ML642

@ML642 ML642 commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Proposed changes

Fix selectByAttribute producing invalid XPath when an option attribute value contains double quotes, such as 12" monitor.

Reuse the existing escapeXPathString helper and add four regression cases covering single, double, mixed, and boundary quotes. Preserve existing whitespace trimming and experimental BiDi behavior.

How you tested

  • Unit tests for the touched package(s)
  • Type definition tests (not applicable; public types are unchanged)
  • Smoke or e2e (real Chrome standalone verification)
node node_modules/vitest/vitest.mjs run packages/webdriverio/tests/commands/element/selectByAttribute.test.ts packages/webdriverio/tests/findStrategy.test.ts

89 tests passed. Three new regression cases failed before the fix.

Local standalone verification script, stored in ignored verification artifacts:

node .agents/verify-artifacts/select-by-attribute-quotes/repro.mjs

64 selection assertions passed in real Chrome: 32 in WebDriver Classic and 32 in BiDi, covering direct options, optgroups, and quoted attribute values.

Oxlint passed for both modified files.

Types of changes

  • Polish (an improvement for an existing feature)
  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update (improvements to the project's docs)
  • Specification changes (updates to WebDriver command specifications)
  • Internal updates (everything related to internal scripts, governance documentation and CI files)

Checklist

  • I have read the CONTRIBUTING doc
  • I have added tests that prove my fix is effective or that my feature works
  • I have added the necessary documentation (not applicable)
  • I have added proper type definitions for new commands (not applicable)

Backport Request

  • This change is solely for v10 and doesn't need to be back-ported
  • Back-ported PR at #XXXXX

Backport applicability to v9 has not been assessed.

Further comments

Pls if you have time , check my other PRs, since i want to continue working on E2E tests (multiremote and so on ) and it is blocked by those two #15980,
#15698

Reviewers: @webdriverio/project-committers

@ML642
ML642 requested a review from a team as a code owner October 20, 2026 17:06
@wdio-bot wdio-bot added the PR: Bug Fix 🐛 PRs that contain bug fixes label Oct 20, 2026
@greptile-apps

greptile-apps Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

@pkg-pr-new

pkg-pr-new Bot commented Oct 20, 2026

Copy link
Copy Markdown

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

PR: Bug Fix 🐛 PRs that contain bug fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants