Scheduled Actions times parameter

I’m trying to speed up some part of a test using the Scheduled Actions feature.

{
  "script": "mobile: scheduleAction",
  "args": [
    {
      "name": "pinAction",
      "intervalMs": 1000,
      "times": 4,
      "maxPass": 4,
      "steps": [
        {
          "type": "gesture",
          "name": "pinStep",
          "payload": {
            "locator": {
              "strategy": "-android uiautomator",
              "selector": "new UiSelector().text(\"1\")"
            },
            "subtype": "click"
          }
        }
      ]
    }
  ]
}

I assume the parameter “times”: 4 indicates that the action with its step should be performed 4 times.
But this is not true and the action is performed only once

Could anyone enlighten me on this issue?

You may check the logcat output to see more details about what happened with the scheduled action. Check appium-uiautomator2-server/app/src/main/java/io/appium/uiautomator2/utils/actions_scheduler/ScheduledActionsManager.java at 1ae907551ff4e874d5f55b17e7aff6349663d505 · appium/appium-uiautomator2-server · GitHub for possible log lines written by the actions scheduler

It is also possible to fetch the action history to know more about how many times it was executed when and which results it produced

Logcat logs:

06-16 02:04:15.124 21059 21089 I appium  : channel read: POST /session/c12042c1-4f49-4fca-bd27-3df2dd50b269/appium/schedule_action
06-16 02:04:15.124 21059 21089 I appium  : ScheduleAction command
06-16 02:04:15.126 21059 21059 I appium  : About to run steps of the scheduled action 'pinAction' (execution 1 of 4)
06-16 02:04:15.126 21059 21089 I appium  : AppiumResponse: {"sessionId":"c12042c1-4f49-4fca-bd27-3df2dd50b269","value":null}
06-16 02:04:15.126 21059 21059 I appium  : About to run the step 'pinStep (gesture)' (1 of 1) belonging to the scheduled action 'pinAction'
06-16 02:04:15.130 21059 21059 I appium  : Waiting up to 10000ms for the device to idle
06-16 02:04:15.210 21059 21059 I appium  : Finished running the step 'pinStep' (type 'gesture') (1 of 1) belonging to the scheduled action 'pinAction'. Step result: {"exception":null,"name":"pinStep","passed":true,"result":null,"timestamp":1718492655126,"type":"gesture"}
06-16 02:04:15.211 21059 21059 I appium  : The scheduled action 'pinAction' has been executed 4 times in total
06-16 02:04:20.158 21059 21089 I appium  : channel read: POST /session/c12042c1-4f49-4fca-bd27-3df2dd50b269/appium/unschedule_action
06-16 02:04:20.160 21059 21089 I appium  : UnscheduleAction command
06-16 02:04:20.169 21059 21089 I appium  : AppiumResponse: {"sessionId":"c12042c1-4f49-4fca-bd27-3df2dd50b269","value":{"repeats":1,"stepResults":[[{"exception":null,"name":"pinStep","passed":true,"result":null,"timestamp":1718492655126,"type":"gesture"}]]}}

It seems that this doesn’t look correct

Yes, there was a bug. fix: The amount of runs to unschedule an action by mykola-mokhnach · Pull Request #645 · appium/appium-uiautomator2-server · GitHub should fix it

Works as expected with [email protected].

Thanks for the fix.