Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

move iOS device type detection onto the setup level #171

Closed
vdelendik opened this issue Jan 10, 2023 · 3 comments
Closed

move iOS device type detection onto the setup level #171

vdelendik opened this issue Jan 10, 2023 · 3 comments
Labels
enhancement New feature or request
Milestone

Comments

@vdelendik
Copy link
Contributor

ios info is pretty slow command and we can determine type at once on setup and remember in metadata.
there is no chance that phone becomes tablet with the same udid :)

if [[ -n "$physical" ]]; then
  deviceClass=$(ios info --udid=$udid | jq -r ".DeviceClass")
  if [ "$deviceClass" = "iPad" ]; then
    export DEVICETYPE='Tablet'
  fi
  if [ "$deviceClass" = "AppleTV" ]; then
    export DEVICETYPE='tvOS'
  fi
else
  export simulatorType=$(cat ${SIMULATORS} | jq -r ".devices[][] | select (.udid==\"$udid\" and .isAvailable==true) | .deviceTypeIdentifier")
  #echo simulatorType: $simulatorType

  if [[ -n "$simulatorType" ]]; then
    export simulator=$(cat ${SIMULATORS} | jq -r ".devices[][] | select (.udid==\"$udid\" and .isAvailable==true) | .name")
  fi

  # define valid DEVICETYPE using $simulatorType
  # Phone: com.apple.CoreSimulator.SimDeviceType.iPhone-13-Pro
  # Tablet: com.apple.CoreSimulator.SimDeviceType.iPad-Pro-12-9-inch-5th-generation
  # tvOS: com.apple.CoreSimulator.SimDeviceType.Apple-TV-4K-2nd-generation-1080p
  #TODO: define strategy for 'Apple Watch' com.apple.CoreSimulator.SimDeviceType.Apple-Watch-38mm
  if [[ "$simulatorType" == *iPad* ]]; then
    export DEVICETYPE='Tablet'
  fi
  if [[ "$simulatorType" == *Apple-TV* ]]; then
    export DEVICETYPE='tvOS'
  fi

fi
@vdelendik vdelendik added the enhancement New feature or request label Jan 10, 2023
@vdelendik vdelendik added this to the 2.4.3 milestone Jan 10, 2023
vdelendik pushed a commit that referenced this issue Jan 11, 2023
@vdelendik
Copy link
Contributor Author

done. special ./metaData/device-$udid.json is generated during setup where we collect all output from ios info --udid=$udud.
as result this pretty slow and most problematic call we do at once.
So far only device type (phone, tablet or tv) is parsed later. Make sure in future don't parse non static values like platform version, device name etc.

@vdelendik
Copy link
Contributor Author

during the testing make sure:

  1. ./metaData/device-$udid.json is generated with common info about device
  2. after services starts/restarts etc appium configuration file has valid deviceType capability (./metaData/$udid.json). Applicable only for non phones, i.e. tablets and TVs. So ideally to setup any iPad for verification.

@dhreben
Copy link

dhreben commented Jan 13, 2023

Verified.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants