Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
3 tasks done
Jayarams99 opened this issue Oct 4, 2024 · 3 comments
Open
3 tasks done

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

Jayarams99 opened this issue Oct 4, 2024 · 3 comments

Comments

@Jayarams99
Copy link

Jayarams99 commented Oct 4, 2024

Do I have the most recent component updates?

  • I use the most recent available driver/plugin and server versions

Is the component officially supported by the Appium team?

  • I have verified the component repository is present under the Appium organization in GitHub

Is there an existing issue for this?

  • I have searched the existing issues

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

  • Operating system:
  • Appium server version (output of appium --version):
  • Appium driver(s) and their version(s) (appium driver list):
  • Appium plugin(s) and their version(s) (appium plugin list):
  • Node.js version (output of node --version):
  • npm version (output of npm --version):
  • Last component(s) version which did not exhibit the problem:
  • Platform and version under test:
  • Real device or emulator/simulator:

Link to Appium Logs

No response

Further Information

No response

@Jayarams99 Jayarams99 added the bug label Oct 4, 2024
@mykola-mokhnach mykola-mokhnach transferred this issue from appium/appium Oct 4, 2024
@mykola-mokhnach
Copy link
Contributor

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
Copy link
Author

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

@ZhongGuan
Copy link

I face the same issue, The execute method is a protected method. It will not be intercepted by proxy. You can create a custom driver that extends the origin one. Override the execute method and make it public.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants