Java-client: GetPlatform API not working on Android

Created on 14 Jun 2018  路  13Comments  路  Source: appium/java-client

Description

The API appiumDriver.getCapabilities().getPlatform().is(Platform.ANDROID)) is returning false even if the Phone is Android. I had raised an issue, but I think a member closed it off without giving due diligence. Please refer the issue #919

Environment

  1. java client build version or git revision if you use some shapshot:5.0.4
  2. Appium server version or git revision if you use some shapshot: 1.7.2
  3. Desktop OS/version used to run Appium if necessary: Mac OS, 10.13.4
  4. Node.js version (unless using Appium.app|exe) or Appium CLI or Appium.app|exe: 8.11.1
  5. Mobile platform/version under test: Android, Samsung Note8, 7.1.1
  6. Real device or emulator/simulator: Real Device

Details

I have set the following capabilities.
DEVICE_NAME, UDID, ACCEPT_SSL_CERTS, AUTO_WEBVIEW, NEW_COMMAND_TIMEOUT, APPIUM_VERSION, FULL_RESET, NO_RESET, PLATFORM_NAME, AUTO_GRANT_PERMISSIONS, APP_PACKAGE and APP_ACTIVITY.

Calling the API appiumDriver.getCapabilities().getPlatform().is(Platform.ANDROID)) is returning false even if the Phone is Android. The Enum Platform (org.openqa.selenium) has Windows, Android, iOS, Linux and other options as well. So I think it is not returning based on System OS as well.

Most helpful comment

@VinnieM I have fixed this. driver.getCapabilities().getCapability('platformName'); will return the platform going forward. Feel free to use this after the new release instead of getting it from session details.

All 13 comments

Ok i will revisit this. Meanwhile you can use sessionDetails until this is resolved.

@SrinivasanTarget Thanks.

@VinnieM platform capabilitytype is officially deprecated at selenium end already so i don't see a point in fixing this at appium end.

Also platformName still holds and provides MAC as platform name. May be that needs to be fixed. May be.

I guess it鈥檚 better to mark the API (getPlatform)deprecated as well... and refer in the doc to use sessionDetails... what do you think?

getPlatform won't get deprecated since it gets the platform from platformName capability incase platform capability type is not set.

Do you want me to raise a new bug on platformName as Mac thingy? I didn鈥檛 notice it since I was only looking at Android.

No need. There is already a workaround for setting platformName capability at Appium Java client side properly during driver creation. It's that getPlatform or getPlatformName needs to be fixed.

I鈥檓 sorry I was referring to the Enum Platform. Can鈥檛 we depreciate that? Or is it used for anything else?

Ok to make it more clear. CapabilityType called platform is officially deprecated but platformName capability and Platform enum still holds. yes, it was confusing to keep both platform and platformName and soplatform capabilityType is deprecated. May be better solution is to use driver.getSessionDetails. Also driver.getCapabilities().getCapability('platformName'); should also return the platform info but it isn't (returns MAC instead). i will fix that soon.

Thanks for clearing up the confusion.

@VinnieM I have fixed this. driver.getCapabilities().getCapability('platformName'); will return the platform going forward. Feel free to use this after the new release instead of getting it from session details.

Thanks for putting in the effort.

Was this page helpful?
0 / 5 - 0 ratings