Solving Common Issues in iOS Testing
Test automation with iOS devices offers some unique challenges. Following are tips and instructions to help you configure iOS devices and your computer for testing, and to avoid issues in that testing:
- Mobile Device Automation Overview
- App States
- Xcode versions
- Killing Apps
- iOS-Specific Commands
- Disabling iOS Features That Can Interfere with Testing
- Special Instructions
Mobile Device Automation Overview
Much of your automation control of iOS devices with Eggplant Functional is done the same as for any other type of system under test (SUT). However, some control options are unique to mobile environments and to iOS specifically.
To learn how to automate your mobile device from Eggplant Functional scripts, see the following resources:
App States
When you work with an iOS app, it is useful to know the state of that app. For our purposes, we work with three iOS app states: Frontmost, Suspended, and Terminated.
Frontmost: The Frontmost app is the app you are currently looking at. If you are multitasking in iOS 9 or later, only the left-side app is Frontmost. The right-side app is considered Suspended.
Suspended: An app that has been Frontmost since it was last Terminated (or since the last device reboot), but that is not currently Terminated.
Terminated: A terminated app is an app that is completely unloaded from memory. This happens in the following circumstances:
- The app is successfully killed via iOS Gateway or Eggplant Functional
- The app crashes on its own
- The app is closed from the Recent Apps list
Multiple Xcode Versions
You must install Xcode, Apple's integrated development environment (IDE), on the machine that's running iOS Gateway. 典型的には新バージョンのiOSが出ると、Appleは新バージョンのXcodeもリリースします。Not all versions of iOS are compatible with all versions of Xcode.
You can have more than one version of Xcode installed on your Mac, though only one version can be active at a given time. The easiest way to see if your active version of Xcode works with the version of iOS on the device you want to test is by using the iOS Gateway Diagnostics tab.
To change the active version of Xcode, follow these steps:
- Open Xcode.
- Go to Xcode > Preferences > Locations.
- From the Command Line Tools drop-down menu, choose the version of Xcode you want to be active.
- Enter an administrator password when prompted.
- Close Xcode.
Killing Apps
You can use the KillApp command in Eggplant Functional. For more about this command, see the KillApp Command.
iOS-Specific Commands
Homeボタン2度押し
On iOS 9以降のデバイスでは、最近使用したアプリのリストに、ホームボタンを2度押しするとアクセスできます。In Eggplant Functional, you can use the TypeText command to automate the action in your SUT by using the following code:
TypeText homeButton, homeButton
Disabling iOS Features that Can Interfere with Testing
In order to successfully test iOS devices in Eggplant Functional, it is necessary to properly configure those devices. Certain features in iOS need to be disabled to prevent test interruptions. Listed below are instructions for disabling iOS features that can interfere with testing.
Updates and Pop-ups
Automated software update notifications and pop-ups in iOS 8 and later can disrupt your testing. If you don’t want to update iOS, or if you want to prevent update notifications from occurring, try one of these methods:
- Block appldnld.apple.com and mesu.apple.com through your router. If you maintain a large group of iOS testing devices that you don’t want to update, consider placing those devices on a separate WiFi network from other devices that should take iOS updates.
- Delete any existing over-the-air (OTA) updates that have already been downloaded to the iOS device:
- Open Settings > General > Storage & iCloud usage on the iOS device.
- Under Storage, tap Manage Storage.
- Find and select the iOS download from the list.
- Tap Delete Update, then confirm that you want to delete the update.
Note that iOS Gateway automation can't begin if there are any pop-up notifications displayed on the iOS device.
Screen Effects
In iOS 9 and later, icons in the user interface move as the device is physically moved. This motion can cause problems with matching images in tests. Icon motion effects can be disabled in Settings. Go to General, then Accessibility, then set Reduce Motion to On.
Text Correction
テキストをiOSデバイス上で入力する場合は、自動修正の候補は通常デフォルトで受け入れられますので、テキストが誤って表示される可能性があります。この問題を回避するには、テストデバイスの自動キーボードオプションを無効にします。
In the iOS Settings app, select General, then Keyboard. Auto-Capitalization(大文字入力)、Auto-Correction(自動修正)、Predictive(予測変換)、およびテキストの表示に悪影響を与えるその他の設定をオフにします。
Special Instructions
File Transfer Commands
When you transfer files using iOS Gateway, the files are not transferred to the actual iOS device, but instead to and from the machine that is running iOS Gateway.
Swapping Apps
TestPlant recommends swapping between apps using the LaunchApp command in Eggplant Functional instead of pressing the home button and navigating the home screen. There are several reasons for this:
- The home screen is particularly "active", making image matching harder and slower.
- It can be difficult to know where an app gets installed, as Apple has sophisticated rules for managing app placement (especially when uninstalling and installing apps). LaunchApp is faster, more maintainable, and less error-prone.
- There is a known bug in Apple's XCTest framework that causes failures after multiple home button presses. To work around that, iOS Gateway will restart automation every 150 times the home button is pressed. That can make user scripts less resilient. LaunchApp can be used to avoid the Apple bug entirely.