java-client icon indicating copy to clipboard operation
java-client copied to clipboard

Commands interface in v9 missing command name/info & args

Open vaind opened this issue 1 year ago • 4 comments

Description

In previous versions of Appium, I've been able to collect timings of executed commands. After update to v9, the commands interface no longer contains the name of the executed command (nor any other information to use in filtering).

Environment

  • Java client build version or git revision if you use some snapshot: 9.3.0
  • Appium server version or git revision if you use some snapshot: 2.11.2
  • Desktop OS/version used to run Appium if necessary: macOS
  • Node.js version (unless using Appium.app|exe) or Appium CLI or Appium.app|exe: v22.4.1
  • Mobile platform/version under test: iOS
  • Real device or emulator/simulator: simulator

Details

Please provide more details, if necessary. The code that worked previously:

driver.activateApp(app.name)

// or following, the result is the same:
// driver.executeScript("mobile:launchApp", ImmutableMap.of("bundleId", app.name));

driver.events.commands.filter { it.name == "activateApp" }

Currently, the commands interface doesn't have any useful identifier for commands triggered by drivers:

"commands": [
    {
      "cmd": "getLogEvents",
      "startTime": 1723451304905,
      "endTime": 1723451304905
    },
    {
      "cmd": "execute",
      "startTime": 1723451304936,
      "endTime": 1723451312314
    }
  ],

vaind avatar Aug 12 '24 08:08 vaind

Sorry, I am confused.

driver.events.commands.filter { it.name == "activateApp" }

The above code snippet does not look like it is a java code

"commands": [
    {
      "cmd": "getLogEvents",
      "startTime": 1723451304905,
      "endTime": 1723451304905
    },
    {
      "cmd": "execute",
      "startTime": 1723451304936,
      "endTime": 1723451312314
    }
  ],

Not sure what is expected to be in this list. As far as I can see the type of a single event was always like that and did not change on the server side: https://github.com/appium/appium/blob/622b245ea38793280d9785a59a0416ce025862fe/packages/types/lib/driver.ts#L571

mykola-mokhnach avatar Aug 12 '24 10:08 mykola-mokhnach

Before update (i.e. with appium java client v8.1.1), the output of print(driver.events) was:

ServerEvents(commands=[CommandEvent(name=activateApp, startTimestamp=1723462917787, endTimestamp=1723462921607)], events=[TimedEvent(name=xcodeDetailsRetrieved, occurrences=[1723462914342]), TimedEvent(name=appConfigured, occurrences=[1723462914342]), TimedEvent(name=resetStarted, occurrences=[1723462914342]), TimedEvent(name=resetComplete, occurrences=[1723462914342]), TimedEvent(name=logCaptureStarted, occurrences=[1723462914694]), TimedEvent(name=simStarted, occurrences=[1723462914942]), TimedEvent(name=wdaStartAttempted, occurrences=[1723462916628]), TimedEvent(name=wdaSessionAttempted, occurrences=[1723462916633]), TimedEvent(name=wdaSessionStarted, occurrences=[1723462916640]), TimedEvent(name=wdaStarted, occurrences=[1723462916640])], jsonData={

so it was possible to filter by the actual command name.

vaind avatar Aug 12 '24 11:08 vaind

Note: I've had to update drivers too so maybe it has something to do with those as well?

vaind avatar Aug 12 '24 11:08 vaind

yes, it might be a result of a bugfix. activateApp is not a "real" command. It is just a value of the script argument in /execute API. That is why the presence of execute command is expected and correct. Having this argument reflected in the events history would be a separate feature.

mykola-mokhnach avatar Aug 16 '24 19:08 mykola-mokhnach

@mykola-mokhnach I have made the fix based on what I understand. Appreciate your review on it. Thank you!

pujagani avatar Jul 11 '25 08:07 pujagani