There are popular frameworks for automating iOS testing like Calabash and Frank but they can only automate your own app which is very limiting. For example you can’t automate pressing the ‘Home’ button, switching to another app, going into airplane mode, rebooting the device, touching anywhere on the screen outside your own app etc
As a concrete example, the new version of the SME iOS client app that we are currently working on implements the Document Provider extension which allows other apps to open an SME document. To automate Picking an SME Document, you’d have to automate the host app which normally you have no control over.
The existing automation testing frameworks don’t provide the required control so a better solution is needed.
Gaining control of your devices
One way of gaining enough control of your testing devices is by jailbreaking them. With a jailbroken device you can SSH into it and run system commands.
To be able to SSH into the device, first install OpenSSH from inside Cydia.
You also need to find the IP address of the jailbroken device by going to Settings/Wi-Fi and touching the name of the wi-fi connection being used.
Then SSH into the device from your computer’s terminal app, for example if the device’s IP address is 192.168.1.23, the following command allows you to SSH into it:
> ssh email@example.com > password: alpine
Activator allows you to run automation commands like for example:
– Run the SME app or bring it to the foreground if already running:
> activator send com.janats.smestorage
Run the Readdle Documents iPad app:
> activator send com.readdle.ReaddleDocsIPad
Simulate touching the home button:
> activator send libactivator.system.homebutton
To list the commands you can run with activator use the following command:
> activator listeners
SimulateTouch allows you to run the following command to simulate a touch on the screen position with x=100 and y=200:
> stouch touch 100 200
With Activator and SimulateTouch you can automate just about everything but you also need to download the screenshots taken by your device which will be processed on your computer to determine if a test has succeeded.
To take a screenshot use the following command:
> activator send libactivator.system.take-screenshot
The device will save the screenshot image to:
You can look at the contents of that folder with the command:
You should see images with names like “IMG_0260.PNG”, the index will increment for each screenshot taken.
To retrieve the image to your computer you can use SCP as follows:
scp firstname.lastname@example.org:/var/mobile/Media/DCIM/100APPLE/IMG_0260.PNG ./
You should then have the screenshot available locally.
Now we’re equipped with the tools we need for the implementation of an automated testing framework.
To where your appetites for the next part of this article please find below a short video of the automated visual testing framework that has been created to easily test iOS Apps.by