clarification request: pure selenium's WebDriverDecorator doesn't work with AppiumFieldDecorator - is RemoteWebElement the issue?
まだ誰も着手していません。
評価
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 初心者へのやさしさ
- 30/100
調査の方向性
再現用の SeleniumDecoratorTest 例から始め、次に、参照されているプロキシ処理の AppiumFieldDecorator.java と、スタックトレースにある ElementInterceptor.java を読みます。WebElement と RemoteWebElement のプロキシに関する前提を比較し、互換性が実現可能かどうかを判断します。期待される動作と必要な変更が、テストまたは文書化された結論によって確立された場合にのみ、issue は完了です。
索引モデルが issue の本文から書いたものです。
説明
Hi appium team!
I was experimenting with selenium's WebDriverDecorator (to decorate WebElement that auto-waits for conditions like clickable&editable&non-readOnly etc), but found out that pure selenium's WebDriverDecorator does not work with AppiumFieldDecorator. I believe this is because WebDriverDecorator creates proxy for WebElement , but AppiumFieldDecorator uses proxies for RemoteWebElement which makes invoking the original element's methods failing. Here is the code to reproduce the exception:
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.*;
// other imports
class SeleniumDecoratorTest {
@Test
void seleniumDecoratorDecorates() {
WebDriver originalDriver = mock(WebDriver.class);
WebElement originalWebElement = mock(WebElement.class);
when(originalDriver.findElement(any())).thenReturn(originalWebElement);
WebDriver decoratedWebDriver = new EventFiringDecorator<>().decorate(originalDriver); // do-nothing decorator, but creates selenium's WebElement decorator/proxy : https://github.com/SeleniumHQ/selenium/blob/1c58e5028bc5eaa94b12b856c2d4a87efa5363f5/java/src/org/openqa/selenium/support/decorators/WebDriverDecorator.java#L331
MobilePageObject mobilePageObject = new MobilePageObject();
PageFactory.initElements(new AppiumFieldDecorator(decoratedWebDriver), mobilePageObject);
mobilePageObject.element.click(); // this fails. likely because the underlying object is expected to be RemoteWebElement: https://github.com/appium/java-client/blob/0b4a430f8e76f48ba166c77a35ab2bd696620741/src/main/java/io/appium/java_client/pagefactory/AppiumFieldDecorator.java#L258
verify(originalWebElement).click(); // verify that the original WebElement was clicked
}
static class MobilePageObject {
@AndroidFindBy(id = "some_id")
WebElement element;
}
}
Exception stacktrace is:
object is not an instance of declaring class
java.lang.IllegalArgumentException: object is not an instance of declaring class
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.checkReceiver(DirectMethodHandleAccessor.java:197)
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:99)
at java.base/java.lang.reflect.Method.invoke(Method.java:580)
at io.appium.java_client.pagefactory.ElementInterceptor.getObject(ElementInterceptor.java:42)
at io.appium.java_client.pagefactory.interceptors.InterceptorOfASingleElement.call(InterceptorOfASingleElement.java:78)
at io.appium.java_client.proxy.Interceptor.intercept(Interceptor.java:78)
at org.openqa.selenium.remote.RemoteWebElement$ByteBuddy$SGYRx3lC.click(Unknown Source)
at io.appium.java_client.pagefactory_tests.SeleniumDecoratorTest.seleniumDecoratorDecorates(SeleniumDecoratorTest.java:27)
versions info : appium-java v10.0.0, (no appium server used - mocked drivers only)
Question: (assuming mismatch of WebElement and RemoteWebElement proxies causes this issue) What is the reason Appium uses RemoteWebElement proxy and not WebElement? I need some hints to understand if using selenium's decorator still possible in theory or not.
Thanks!
- 主要言語
- Java
- スター
- 1.3k
- フォーク
- 752
- 平均マージ
- 6日 21時間
- マージ済み PR(30日)
- 8
コントリビューションガイド
このリポジトリのコントリビューションガイドは索引されていません
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
appium/java-client のほかの issue
-
難易度 4/5 3〜5日 初心者へのやさしさ 55/100
appium/java-client#2448 · コメント 1 件 ·
-
難易度 5/5 1週間以上 初心者へのやさしさ 25/100
appium/java-client#2426 ·
-
bug
難易度 4/5 3〜5日 初心者へのやさしさ 50/100
appium/java-client#2372 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 30/100
appium/java-client#2341 · コメント 1 件 ·
-
難易度 5/5 1週間以上 初心者へのやさしさ 15/100
appium/java-client#2323 ·
appium/java-client の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
-
bug needs triage
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
-
難易度 1/5 1時間未満 初心者へのやさしさ 94/100
objectionary/hone-maven-plugin#1061 ·
-
type:bug
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100