Skip to content

Comments

Improve PageAction selector robustness by prioritizing test-id attributes#280

Open
Copilot wants to merge 5 commits intomainfrom
copilot/improve-pageaction-logging-logic
Open

Improve PageAction selector robustness by prioritizing test-id attributes#280
Copilot wants to merge 5 commits intomainfrom
copilot/improve-pageaction-logging-logic

Conversation

Copy link
Contributor

Copilot AI commented Feb 8, 2026

PageAction記録ロジックの改善

修正内容

1. XPathエスケープ処理の修正

  • 'を使用するアプローチからXPath 1.0標準の方法に変更
  • シングルクォートのみ: ダブルクォートで囲む
  • ダブルクォートのみ: シングルクォートで囲む
  • 両方含む: concat()関数を使用
  • XPath仕様に準拠した正しいエスケープ処理を実装

2. DATA_TESTID_ATTRIBUTES を public static に変更

  • RobulaPlusOptions からアクセスできるように修正
  • TypeScript コンパイルエラーを解消

3. テストの追加

  • シングルクォートを含む値のテスト
  • ダブルクォートを含む値のテスト
  • 両方のクォートを含む値のテスト(concat使用)
  • テキストコンテンツのクォート処理テスト

テスト結果

  • 13のrobula-plusテスト全てパス
  • 538の既存テスト全てパス
  • ビルド正常完了
Original prompt

This section details on the original issue you should resolve

<issue_title>PageAcitonの記録ロジックの改善</issue_title>
<issue_description>## 課題
PageActionの記録ロジックにおいて、生成されたセレクタに脆弱な部分があり、コマンド共有時に要素を発見できなくなっている

要点

packages/extension/src/lib/robula-plus/index.ts で、以下の修正を行う。

  • aria-labelは使用しない
    • 多言語化しているサービスだと、ユーザーの言語によって変わってしまうため。
  • data-testid系を優先的に使用する
    • 言語によらないため、より堅牢性が高い
    • data-testid, data-test-id などのパターンについても対応する</issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 3 commits February 8, 2026 02:20
Co-authored-by: ujiro99 <677231+ujiro99@users.noreply.github.com>
Co-authored-by: ujiro99 <677231+ujiro99@users.noreply.github.com>
Co-authored-by: ujiro99 <677231+ujiro99@users.noreply.github.com>
Copilot AI changed the title [WIP] Improve PageAction recording logic for better robustness Improve PageAction selector robustness by prioritizing test-id attributes Feb 8, 2026
Copilot AI requested a review from ujiro99 February 8, 2026 02:30
@ujiro99 ujiro99 marked this pull request as ready for review February 11, 2026 22:52
@ujiro99 ujiro99 requested a review from Copilot February 11, 2026 22:53
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves the robustness of generated RobulaPlus XPath selectors for PageAction recording by prioritizing language-agnostic data-test* attributes and excluding locale-dependent aria-label.

Changes:

  • Added a data-test*-first transformation (transfAddDataTestId) and reordered the transformation pipeline to prefer stable attributes early.
  • Blacklisted aria-label so it won’t be used in generated selectors.
  • Introduced XPath value escaping and added Vitest coverage for data-test* prioritization and aria-label exclusion.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
packages/extension/src/lib/robula-plus/index.ts Adds data-test* prioritization + pipeline reorder, blacklists aria-label, and introduces XPath escaping helper.
packages/extension/src/lib/robula-plus/index.test.ts Adds unit tests validating data-test* prioritization and aria-label exclusion behavior.
Comments suppressed due to low confidence (1)

packages/extension/src/lib/robula-plus/index.ts:27

  • Because data-test* attributes are now handled explicitly in transfAddDataTestId, also adding them to attributePriorizationList means transfAddAttribute can generate the same [@data-testid='...'] predicate again (for values that pass isAttributeUsable). Since temp = [...new Set(temp)] de-dupes by object identity (not XPath string), this can inflate the search space. Consider either (1) skipping DATA_TESTID_ATTRIBUTES inside transfAddAttribute, or (2) de-duping generated XPaths by x.getValue().
  private attributePriorizationList: string[] = [
    ...RobulaPlus.DATA_TESTID_ATTRIBUTES,
    "name",
    "class",
    "title",
    "alt",
  ]

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Co-authored-by: ujiro99 <677231+ujiro99@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Feb 21, 2026

Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • www.google-analytics.com
    • Triggering command: /opt/hostedtoolcache/node/24.13.0/x64/bin/node /opt/hostedtoolcache/node/24.13.0/x64/bin/node --conditions node --conditions development /home/REDACTED/work/selection-command/selection-command/node_modules/tinypool/dist/entry/process.js (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

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.

PageAcitonの記録ロジックの改善

2 participants