Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

clarification request: pure selenium's WebDriverDecorator doesn't work with AppiumFieldDecorator - is RemoteWebElement the issue?

未关闭
#2,368 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
5/5
预计耗时
一周以上
新手友好度
30/100
Issue 类型
缺陷
描述清晰度
需要澄清
活跃度
停滞
技术栈
java
领域
mobile, testing

调研方向

先从可复现的 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
派生
755
平均合并
5 天 14 小时
30 天内合并 PR
8

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 有 Pull Request 模板
  • 没有贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

appium/java-client 的其他 Issue

查看 appium/java-client 的全部 Issue

相似的 Issue

更多 Java Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。