mobile-dev-inc / maestro

Painless Mobile UI Automation
https://maestro.mobile.dev/
Apache License 2.0
5.81k stars 273 forks source link

iOS miss `-` Launch Arguments when value type is Bool #2113

Open littlema0404 opened 3 days ago

littlema0404 commented 3 days ago

Is there an existing issue for this?

Steps to reproduce

appId: xxx
- launchApp:
    clearState: true
    permissions:
      userTracking: deny
    arguments:
        argumentA: true
        argumentB: 1
        argumentC: "abc"

Actual results

CommandLine.arguments // ["argumentA", "true", "-argumentB", "1", "-argumentC", "abc"]

Expected results

CommandLine.arguments // ["-argumentA", "true", "-argumentB", "1", "-argumentC", "abc"]

About app

Closed source iOS native app

About environment

Java version

openjdk version "17.0.10" 2024-01-16 LTS
OpenJDK Runtime Environment Corretto-17.0.10.7.1 (build 17.0.10+7-LTS)
OpenJDK 64-Bit Server VM Corretto-17.0.10.7.1 (build 17.0.10+7-LTS, mixed mode, sharing)

OS and its version

macOS 14.6.1(23G93)

Processor architecture

M2 arm64

Logs

Logs ``` ```

Maestro version

1.38.1

How did you install Maestro?

install script (https://get.maestro.mobile.dev)

Anything else?

- This is the specification for iOS launch arguments. Currently, only when the YAML value type is Bool, the - sign is not added. However, if the value type is Int or String, the - sign is automatically added.

When I use UserDefaults to retrieve argumentA, I won’t be able to find it.

let standardDefaultsDict = UserDefaults.standard.dictionaryRepresentation()
standardDefaultsDict["argumentA"] as? Bool // will get nil
standardDefaultsDict["argumentB"] as? Int // will get 1

I think the issue might be here.

https://github.com/mobile-dev-inc/maestro/blob/main/maestro-ios-driver/src/main/kotlin/util/IOSLaunchArguments.kt#L10-L18

It seems intentional, but I don’t understand why only boolean values are not prefixed with -.

linear[bot] commented 3 days ago

MA-2407 iOS miss `-` Launch Arguments when value type is Bool

Fishbowler commented 2 days ago

Looks like the intent in #1018 was that you'd access booleans differently?

littlema0404 commented 2 days ago

Looks like the intent in https://github.com/mobile-dev-inc/maestro/pull/1018 was that you'd access booleans differently?

Yeh, for here a little bit confused.

like example from #1018

 ProcessInfo.processInfo.arguments.contains("isMaestro")

The contains method only indicates whether the ‘isMaestro’ launch argument is present, but it doesn’t allow me to retrieve its boolean value.

So I have to use UserDefault to retrieve its boolean value. But I can't find it