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

Bug: Two extra spaces in capability "systemPort ," makes it bug prone when trying to fetch value for this key. I was fetching this value for "systemPort" without spaces and got null. With space, got right result.

Open PramodKumarYadav opened this issue 4 years ago • 0 comments

The problem

Appium capability "systemPort " has extra spaces in the end. I was trying to fetch this capability based on the key "systemPort " without spaces and was getting null. On careful analysis I saw there were extra spaces after text "systemPort " and with adding those, I could fetch system port.

Below is an example. [INFO] 2021-10-17 13:26:27,260 AvailableDevices: all available capability names: [app, appPackage, appWaitActivity, automationName, avd, avdArgs, avdLaunchTimeout, avdReadyTimeout, databaseEnabled, desired, deviceApiLevel, deviceManufacturer, deviceModel, deviceName, deviceScreenDensity, deviceScreenSize, deviceUDID, javascriptEnabled, locationContextEnabled, networkConnectionEnabled, pixelRatio, platform, platformName, platformVersion, statBarHeight, systemPort , takesScreenshot, udid, viewportRect, warnings, webStorageEnabled]

Details

While trying to fetch systemPort with extra spaces. results in correct value (see below). public static void freeDevice(AppiumDriver driver){ Capabilities capabilities = driver.getCapabilities(); log.info("capabilities: {}", capabilities); log.info("avd: {}", capabilities.getCapability("avd")); log.info("udid: {}", capabilities.getCapability("udid")); log.info("systemPort: {}", capabilities.getCapability("systemPort ")); log.info("all available capability names: {}", capabilities.getCapabilityNames()); }

[INFO] 2021-10-17 13:26:27,259 AvailableDevices: avd: Pixel_3_API_31 [INFO] 2021-10-17 13:26:27,259 AvailableDevices: udid: emulator-5554 [INFO] 2021-10-17 13:26:27,259 AvailableDevices: systemPort: 8200 [INFO] 2021-10-17 13:26:27,260 AvailableDevices: all available capability names: [app, appPackage, appWaitActivity, automationName, avd, avdArgs, avdLaunchTimeout, avdReadyTimeout, databaseEnabled, desired, deviceApiLevel, deviceManufacturer, deviceModel, deviceName, deviceScreenDensity, deviceScreenSize, deviceUDID, javascriptEnabled, locationContextEnabled, networkConnectionEnabled, pixelRatio, platform, platformName, platformVersion, statBarHeight, systemPort , takesScreenshot, udid, viewportRect, warnings, webStorageEnabled]

Without these extra spaces in the field "systemPort ", the systemPort is returned as null

Code To Reproduce Issue [ Good To Have ]

Use below method and you can see that when you dont give extra spaces in systemPort, you will get null as returned value.

 public static void freeDevice(AppiumDriver driver){
        Capabilities capabilities = driver.getCapabilities();
        log.info("capabilities: {}", capabilities);
        log.info("avd: {}", capabilities.getCapability("avd"));
        log.info("udid: {}", capabilities.getCapability("udid"));
        log.info("systemPort: {}", capabilities.getCapability("systemPort"));
        log.info("all available capability names: {}", capabilities.getCapabilityNames());
    }

PramodKumarYadav avatar Oct 17 '21 11:10 PramodKumarYadav