appium / java-client

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

Commands interface in v9 missing command name/info & args #2219

Open vaind opened 3 months ago

vaind commented 3 months ago

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

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
    }
  ],
mykola-mokhnach commented 3 months ago

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

vaind commented 2 months ago

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 commented 2 months ago

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

mykola-mokhnach commented 2 months ago

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.