Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

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

Đang mở
#2,368 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
5/5
Thời gian dự kiến
Hơn một tuần
Mức phù hợp với người mới
30/100
Loại issue
Lỗi
Độ rõ ràng
Cần làm rõ
Mức độ hoạt động
Đình trệ
Công nghệ
java
Lĩnh vực
mobile, testing

Hướng nghiên cứu

Bắt đầu với ví dụ SeleniumDecoratorTest có thể tái hiện, sau đó đọc AppiumFieldDecorator.java tại phần xử lý proxy được tham chiếu và ElementInterceptor.java từ stack trace. So sánh các giả định về proxy của WebElement và RemoteWebElement rồi xác định liệu khả năng tương thích có khả thi hay không; issue chỉ hoàn tất khi hành vi mong đợi và mọi thay đổi cần thiết được xác lập bằng một test hoặc một kết luận được lập tài liệu.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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!

Ngôn ngữ chính
Java
Star
1.3k
Fork
755
Merge trung bình
5 ngày 14 giờ
Pull request đã merge (30 ngày)
8

Chuẩn bị môi trường

  • Không có Dockerfile hay tệp Docker Compose
  • Có mẫu pull request
  • Không có hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của appium/java-client

Tất cả issue của appium/java-client

Issue tương tự

Thêm issue về Java

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.