You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The PageFactory.initElements(element, this) method overrides all object's fields, including assigned final fields.
I think this behavior is not correct - final fields should not be changed by reflection.
Even IntelliJ hints that the assigned final fields should not change:
The problem occurs in the selenium-support artifact
It is not related to the browser vendor or browser version
Proposed solution:
The DefaultFieldDecorator should ignore final fields when decorating objects.
Additionally: the DefaultFieldDecorator should also ignore static fields when decorating objects.
Exception in thread "main" java.lang.IllegalStateException: this.element != element
at Component.<init>(Component.java:12)
at CardComponent.<init>(CardComponent.java:12)
at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1708)
at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)
at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:575)
at java.base/java.util.stream.AbstractPipeline.evaluateToArrayNode(AbstractPipeline.java:260)
at java.base/java.util.stream.ReferencePipeline.toArray(ReferencePipeline.java:616)
at java.base/java.util.stream.ReferencePipeline.toArray(ReferencePipeline.java:622)
at java.base/java.util.stream.ReferencePipeline.toList(ReferencePipeline.java:627)
at MainApp.main(MainApp.java:20)
### Operating System
Linux, Windows
### Selenium version
java 4.24.0
### What are the browser(s) and version(s) where you see this issue?
Firefox 129.0.2
### What are the browser driver(s) and version(s) where you see this issue?
geckodriver 0.34.0
### Are you using Selenium Grid?
_No response_
The text was updated successfully, but these errors were encountered:
@mk868, thank you for creating this issue. We will troubleshoot it as soon as we can.
Info for maintainers
Triage this issue by using labels.
If information is missing, add a helpful comment and then I-issue-template label.
If the issue is a question, add the I-question label.
If the issue is valid but there is no time to troubleshoot it, consider adding the help wanted label.
If the issue requires changes or fixes from an external project (e.g., ChromeDriver, GeckoDriver, MSEdgeDriver, W3C),
add the applicable G-* label, and it will provide the correct link and auto-close the
issue.
After troubleshooting the issue, please add the R-awaiting answer label.
What happened?
The
PageFactory.initElements(element, this)
method overrides all object's fields, including assigned final fields.I think this behavior is not correct - final fields should not be changed by reflection.
Even IntelliJ hints that the assigned final fields should not change:
The problem occurs in the
selenium-support
artifactProposed solution:
DefaultFieldDecorator
should ignore final fields when decorating objects.DefaultFieldDecorator
should also ignore static fields when decorating objects.How can we reproduce the issue?
index.html
MainApp.java
CardComponent.java
Component.java
Relevant log output
The text was updated successfully, but these errors were encountered: