[🐛 Bug]: JPMS: `isDisplayed.js` / `getAttribute.js` not found on the module path (`Read.resourceAsString` is caller-sensitive)
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
調査の方向性
Read java/src/org/openqa/selenium/remote/codec/w3c/W3CHttpCommandCodec.java, java/src/org/openqa/selenium/remote/RemoteScript.java, and java/src/org/openqa/selenium/io/Read.java, along with the relevant module descriptors. Reproduce the failure using the provided Maven project on the module path, then check both resource-loading call sites. Done when the affected resources load on the module path without requiring consumers to add the workaround directive.
索引モデルが issue の本文から書いたものです。
説明
Description
When Selenium runs on the module path, W3CHttpCommandCodec cannot load JavaScript files it needs, so WebElement#isDisplayed() and #getAttribute() fail with any browser (no Grid).
Works on the class path.
java.lang.IllegalArgumentException: Resource not found: /org/openqa/selenium/remote/isDisplayed.js
at org.seleniumhq.selenium.api/org.openqa.selenium.io.Read.resourceAsString(Read.java:71)
at org.seleniumhq.selenium.remote_driver/org.openqa.selenium.remote.codec.w3c.W3CHttpCommandCodec.lambda$executeAtom$0(W3CHttpCommandCodec.java:364)
Reproducer
Simple Maven project that showcases the issue: selenium-bug-remote-resource-jpms.zip
Only dependency is org.seleniumhq.selenium:selenium-remote-driver:4.52.0; no browser needed. Run with:
mvn package
java -p target/classes:target/lib -m repro/repro.Main # fails: Resource not found
java -cp 'target/classes:target/lib/*' repro.Main # works
# Workaround works too
java --add-opens org.seleniumhq.selenium.remote_driver/org.openqa.selenium.remote=org.seleniumhq.selenium.api -p target/classes:target/lib -m repro/repro.Main
Cause
- org.openqa.selenium.remote.codec.w3c.W3CHttpCommandCodec is in module
org.seleniumhq.selenium.remote_driver - org.openqa.selenium.io.Read is in module
org.seleniumhq.selenium.api
W3CHttpCommandCodec now calls Read.resourceAsString(getClass(), "/org/openqa/selenium/remote/isDisplayed.js"); and Read calls clazz.getResourceAsStream(path).
This fails, because Class#getResourceAsStream is caller-sensitive: the package must be opened to the caller's module, i.e. org.seleniumhq.selenium.api. But remote_driver opens org.openqa.selenium.remote only to org.seleniumhq.selenium.json.
Same issue in RemoteScript (resource bidi-mutation-listener.js).
Suggested fix
Two options that come to mind:
- Load the resource in the module that owns it, e.g.
Read.toString(getClass().getResourceAsStream(path))(plus null check) inW3CHttpCommandCodecandRemoteScript. - Alternative: Add
opens org.openqa.selenium.remote to org.seleniumhq.selenium.apito the module descriptor oforg.seleniumhq.selenium.remote_driver.
Read.resourceAsString(Class, String) can never work for non-open packages of other named modules, so it might be worth deprecating.
Workaround
Consumers must add the missing opens directive manually when running on the module path:
--add-opens org.seleniumhq.selenium.remote_driver/org.openqa.selenium.remote=org.seleniumhq.selenium.api
Reproducible Code
// module-info.java
module repro {
requires org.seleniumhq.selenium.remote_driver;
}
// repro/Main.java
package repro;
import java.util.Map;
import org.openqa.selenium.remote.Command;
import org.openqa.selenium.remote.DriverCommand;
import org.openqa.selenium.remote.SessionId;
import org.openqa.selenium.remote.codec.w3c.W3CHttpCommandCodec;
public final class Main {
public static void main(String[] args) {
var command = new Command(new SessionId("s"), DriverCommand.IS_ELEMENT_DISPLAYED, Map.of("id", "e"));
System.out.println(new W3CHttpCommandCodec().encode(command).getUri());
}
}
Debugging Logs
_(none, stack trace above)_
- 主要言語
- Java
- スター
- 34.6k
- フォーク
- 8.7k
- 平均マージ
- 1日 23時間
- マージ済み PR(30日)
- 86
環境構築
このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
SeleniumHQ/selenium のほかの issue
-
難易度 1/5 1時間未満 初心者へのやさしさ 82/100
SeleniumHQ/selenium#18323 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
SeleniumHQ/selenium#17843 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
[java] DriverFinderTest property fixture doesn't clear/restore selenium.webdriver.verbose再び着手できるかも @stefanpoia が 25 日前に担当しましたが、オープン中のプルリクエストはありません。 オープン
難易度 1/5 1〜3時間 初心者へのやさしさ 88/100
SeleniumHQ/selenium#17836 · コメント 3 件 ·
メンテナーはふだん 1 日以内に返信
-
[Bug]: [py] Generated bidi.UserAgentClientHints is empty — inline CDDL params drop the command対応中かも @titusfortner が 3 日前に担当しました。 オープンC-py OS-mac
SeleniumHQ/selenium#18312 · 担当者 2 名 ·
メンテナーはふだん 1 日以内に返信
-
A-needs-triaging B-grid I-defect OS-mac
難易度 4/5 3〜5日 初心者へのやさしさ 45/100
SeleniumHQ/selenium#18304 · コメント 3 件 ·
メンテナーはふだん 1 日以内に返信
SeleniumHQ/selenium の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
btraceio/jafar#228 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 83/100
jenkinsci/git-client-plugin#1807 ·
-
area-templates triage:bot-seen triage:needs-human
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
microsoft/aspire#22356 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
apache/flink-agents#1395 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 77/100
floci-io/floci#8666 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信