How can I automate WiFi testing using Xcode Instruments? - ios

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

Related

How does a UI app inspectors (like the one in Appium) work?

Appium has a way to inspect the view hierarchy of an app using an inspector. I am interested in building one myself.
I know the overview answer of: it uses some webdriver to accomplish this. But how?
It puzzles me that a separate iOS app can some how communicate to another app, and show even its screen.
How does it work under the hood? or how does the iOS app communicate to the UI inspector to send its screen shots and hierarchy?
It puzzles me that a separate iOS app can some how communicate to another app, and show even its screen.
Yes! Apps should not be able to do this. But there exists a special kind of app, built just for testing, which IS able to do this.
The way this is done is using Apple's XCUITest framework. When you write an XCUITest in XCode, it builds a special app which is able to start your test app and then communicate with it using the XCUITest methods. These methods allow you to inspect elements in the view.
In order to create a view tree, you start at the root view and iterate over the children, building out a tree with a tree traversal.
Normally, the XCUITest app exits when your test script finishes, which means you won't be able to access it from a desktop app for viewing the tree as it updates. If you write your test script to run an infinite loop and open a network port for communication with an outside process, now you can build your viewer. This is exactly what Appium does, so I suggest you check out the appium source code and maybe just use that?
More information in this blog post
[edit]: Oh yeah, Appium uses Feacebook's WebDriverAgent project as the script that runs on the app. So WebDriverAgent is basically an XCUITest script which runs a server and can take commands during a test. Appium does a ton of work to bundle and package it into the special kind of companion app that is able to access your app, installs it on the iOS device, and then runs the test. WebDriverAgent has a command which iterates over the UIHierarchy and returns the whole tree.

How to dismiss or suppress permission issue automatically related to Contacts, Camera, Microphone in iOS Application

I have been working on a project wherein i made a framework where i automatically test the SDK my company is developing.
I have created my dummy sample application for all the platforms(iOS, Android, OSX, Windows) which makes use of this SDK and i thereby test this SDK, call the SDK API's do my work.
Now my question is for iOS i get permission alerts for Contacts, Camera and Microphone first time whenever i use the API's of my SDK which internally is invoking something in iOS framework. Is there a way i can automatically give this permission to my application ?? i know it's iOS own Security concern and it's correct. But how do i bypass it.
I see there is Apple's XCUITest framework but i don't want to open my application via it.
Right now i handle this alert manually but i need to implement Continuous Integration(using ios-deploy), i have done everything but i can't handle these alerts automatically.
Can someone please help me.. Thanks!!

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.

How to automate actions performed on the iPhone simulator?

Right now I am automating tests for an app using UIAutomation class. But my app has certain features which, I believe, can't be tested using just UIAutomation. For example, there is a feature that if a new contact is added to the addressbook, a popup is shown in the app. To test this feature a new contact needs to be added to the address book the popup should be checked. But UIAutomation automates user actions only within the target app. Can anyone tell me how can I automate these type of actions(preferably using scripts)?
i would recommend you automate with Sikuli. its mucvh easier to record and play. also u can any kind of alerts or popups

UI Recorder template not found in instruments

I have installed xcode4 and used profiling for leaks and allocations, etc. However, I don't find the new UI Recorder template in instruments under iOS however I find a template named Automation. Please let me know how to enable UI Recorder template in instruments for xcode 4 and also any idea what is this Automation template for?
Thanks.
There is no UI Recorder template for iOS applications, it can't be done. The Automation template is for automated UI unit tests. It runs a JavaScript test script that you put together that is able to drive the UI and record successes or failures. You can find details about UI Automation in the Instruments Users Guide.
It helps a lot to read the documentation first and then ask specific questions later, when you don't understand something in the documentation or something doesn't work as expected. If you don't read the documentation, you'll just get answers where people either reiterate the documentation to you, or point you to the documentation.
Well, instead you can record the user actions of the iOS simulator.
Make sure that the 'Enable access for assistive devices' setting is enabled in your Universal Access pane of System Preferences.
In instruments, just choose the 'UI Recorder' template (Mac OS X).
Start the iOS simulator and connect it to instruments by attaching the 'iPhone simulator' process in the 'choose target' selection box.
Press 'Record'.
Welcome!
I've just tried Rolands suggestion below and it works - not perfectly, it misses to play some recorded interactions, but it works and creates an editable script! I'm using Xcode 4.6.2, Instruments 4.6 and running iPhone 6.1 Simulator.

Resources