Access an iPads Device Settings using UIAutomation - ios

Can you access the iPad Device settings using the UIAutomation instrument?
I can use deactivateAppForDuration, but that does not allow me to exit the app navigate to the settings page, change a setting, and navigate back to the app and move on.
any suggestion?

No, you cannot automate anything outside of the target application as of right now. When your app leaves the foreground the automation tool loses control until it returns (if it does at least).

Related

How can I automate WiFi testing using Xcode Instruments?

I want to automate the UI flow on iOS, specifically below steps:
User taps on Settings
Opens WiFi options
Taps on the desired SSID
Enters Username and Password
Taps connect
Opens up a browser
I can do similar flow on Android with Android Debug Bridge. In Xcode Instruments, I don't see any WiFi options listed. Do we have any other tool to automate UI flow on iOS?
The standard is now to use UI Unit tests from XCode. Automation via instruments is deprecated (as far as I know).
However you can automate iOS itself, only the app you are testing. So accessing the settings like this will not work.
I'm also wondering why you need to test this. It's part of iOS and not your app. Therefore it's Apple's job to test it. You can just assume it works.
There is no way to do this on iOS. You may want to look into something like http://www.tapster.io.
Also ui_automation is remove from Xcode 8, so theres that.
I'm having pretty good luck with http://www.tapster.io

How to Programatically Turn on Guided Access on iPad/iOS Device?

I am currently automating an app for iPad that needs to be set in Guided Access mode to work. I'm using Java with Selenium webdriver inside Eclipse. The app is all setup and being deployed through Xcode and I can interact with it just fine with the iOS driver.
The problem is the user cannot login until the iPad is set to Guided Access mode on this app. I know you can turn it on by triple clicking the Home button very quickly but I have not found a way to do that using code inside my tests.
Is there a way to send keyevents specific to the iPad Home button OR is there a way to set Guided Access mode programatically? Maybe set it in the capabilities before the iOS driver/app launches?
I'm not aware of any way to send events to the home button (pretty sure this wouldn't be possible).
You can programmatically enable / disable guided access however, using UIAccessibilityRequestGuidedAccessSession. In order for this to work, your device must be supervised using MDM and have a profile installed that enables single app mode for your application.
More details here: https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIKitFunctionReference/#//apple_ref/c/func/UIAccessibilityRequestGuidedAccessSession

how to deal with jump to other app when test monkey with UIAutomation?

I'm testing my app with UIAutomation(monkey), and it may click a button and open safari,
how can I do if I want to go back to my testing app ?
You can keep the app from ever leaving the foreground by turning on Guided access.
On the device. You can enable Guided Access at Settings > General > Accessibility > Guided Access.
Once your app is open you can tap the home button 3 times and turn it on.
With UIAutomation, add a delay right at the beginning of the Monkey script. When running the script, this will give you some time to start Guided Access after the app was launched.
More on Guided Access: http://support.apple.com/kb/ht5509

What applescript commands can be sent to iOS Simulator?

I know you can tell the iOS Simulator to quit with applescript. Can you tell it to go "home" from the current app? And then click on the app's icon to relaunch it? This would be useful for me for Application Tests that need to verify background tasks complete and numerous other cases.
Any AppleScriptable app must export a scripting dictionary in order for AppleScript to know what its commands are. You can see any app's dictionary by opening the app in Script Editor.
Note that even if an app doesn't provide script commands for what you want, System UI Scripting or Automator can likely still be used to drive its UI. (For example, to choose the Home or Rotate commands in iOS Simulator's menu bar.)
There's also iOS-specific UI automation stuff you can do from the Instruments app that comes with Xcode.
The iOS Simulator does not directly support AppleScript. It doesn't have a scripting dictionary. This means that the only real way to manipulate it in AppleScript is to use the UI commands that work for any application.

Disable deleting application by tap-and-hold

Usually on a long press of a third-party application icon, it will give you the option to delete the app. Is there any way to disable that option, the way it seems to be with the preloaded applications on iPhone?
It's not possible to do it from within the app.
You could, however, configure the parental settings on the device to disallow removing applications (Settings -> General -> Restrictions), but you would need to do it on each device you want the feature enabled, and the setting will apply for all third party apps, not only yours.
Nope, you can't disable it. If you're developing some enterprise application where the iPad is supposed to run only your app and nothing else, I suggest getting a case or something along those lines to block the "home" button on the iPad.

Resources