appium / java-client

Java language binding for writing Appium Tests, conforms to W3C WebDriver Protocol
Apache License 2.0
1.22k stars 757 forks source link

bug: unable to intercept click action using appium proxy #2239

Open Jayarams99 opened 3 weeks ago

Jayarams99 commented 3 weeks ago

Do I have the most recent component updates?

Is the component officially supported by the Appium team?

Is there an existing issue for this?

Current Behavior

This issue is related to https://github.com/appium/java-client/blob/master/docs/The-event_firing.md .

The proxy method is not able to intercept click action, only driver based methods are intercepted

Expected Behavior

Please provide a fix or documentation on how to intercept webelement method calls

Minimal Reproducible Example

MethodCallListener listener = new MethodCallListener() {
    @Override
    public void beforeCall(Object target, Method method, Object[] args) {
        if (method.getName().equals("execute")) {
            System.out.println(args[0].tostring());
        }

};

IOSDriver decoratedDriver = createProxy(
        IOSDriver.class,
        new Object[] {new URL("http://localhost:4723/"), capabilities},
        new Class[] {URL.class, Capabilities.class},
        listener
);

decoratedDriver.findElement(Appium.id("id")).click();

Environment

Link to Appium Logs

No response

Further Information

No response

mykola-mokhnach commented 3 weeks ago

It is only possible to wrap instances with proxies upon creation. And since WebElement instances creation is incapsulated in the driver the above isn't possible.

The only workaround would be to intercept the driver's execute method as eventually all WebElement's method calls are routed there.

Jayarams99 commented 1 week ago

I tried to intercept execute call but it is not showing the click calls. Please find the code snippet for the same in initial bug details