Q: How could I detect if target application hide to background in instruments? - ios-ui-automation

I'm trying to test monkey test on iOS Xcode instruments, and there exist a problem:
If the target app be hided to background, the script would be stopped after manually launch the app.
How could I detect the app be hided to background? Then I could kill the process and run script again or launch the app.
I used command line as following:
instruments -D "${UIA_resultPATH}/monkey/$DATE" -t "${UIA_automationPATH}/Template/Template.UIAutoMonkey.tracetemplate" -w "${UIA_device}" "${UIA_appPATH}" -e UIASCRIPT "${UIA_automationPATH}/UIAutoMonkey/test_suite.js"

Related

Instrumentation Test not starting on Android only on a real device. Working on Simulator

I am mainly facing an issue with running detox tests on android real device. The main problem I face is that await device.launchApp() just doesn't launch the app. After adding some log traces I see that android instrumentation command is the one that is not actually starting the app. Detox internally calls the command /Users/<uname>/Library/Android/sdk/platform-tools/adb -s 39bc3158 shell am instrument -w -r -e detoxServer ws://localhost:51414 -e detoxSessionId 5c04ed58-aa77-64bb-aa2b-3a008f21ac2b -e debug false com.realapp.app.test/androidx.test.runner.AndroidJUnitRunner. This command hangs and Process Times out after sometime and doesn't launch the app.
If I create an instrumentation test from android studio also I am seeing the same issue and this problem only occurs on a real device and not on a simulator. Simulator works absolutely fine and the test cases run smooth.
I have looked into different issues, used 4.1.2 android studio, Invalidated cached and restarted upgraded to latest beta android studio and nothing seems to help.
Also the instrumentation tests run fine on the real device if i open the app manually after starting the tests. The tests are just not launching the app automatically.

react-native run-ios without build

How can I run the application without rebuilding the project (of course the app is installed on the relevant simulator from previous run)
I run the application on iOS (for instance) like this:
react-native run-ios --simulator='iPhone 8'
Thanks to this post, I found this command:
xcrun simctl launch booted <APP_BUNDLE_ID>
It will launch the application which pre-installed on the current running simulator (if we have 2 or more simulators running simultaneously, we will need to pick one by its simulator ID).
Depends on what you're trying to do. If you just need to reload, then you can do it through the developer menu as #Kraylog says. Or via ⌘R if the application is already open and running.
If you've closed packager/metro bundler, then you'll want to start that with react-native start. You should then be able to just click the app icon in the simulator to run it + reloading as stated above as needed.

How to Allow quick development in Appcelerator Studio?

How do I re-enable the below behavior?
I USED to have the below behavior...now I don't. I have to re-compile the whole project for every change which is killing productivity for me.
I cut and pasted the below text from another question as it explains it much better than I can....
For an iphone simulator build, the .js files are run directly by the simulator without going through the compile step needed for a distribution build. While this saves some time by itself, the real advantage is that the simulator will dynamically use whatever changes you make to a .js file when you navigate to a window using an external .js reference (i.e. the url property). So changes to app.js still need to relaunch the project. But for windows opened later, you can navigate to the window to see how it looks or test code, then just hit the back button in the navigation bar, tweak the .js, and navigate back to the desired window and immediately see the new layout or test the code changes.
This makes tweaking UI layout stuff incredibly fast compared to the android emulator, not to mention code/debug cycles for some *.js logic is as quick as backing up a screen, revising the code, and showing the screen again. Then when you get the logic worked out, switch to android and retest.
If you have Appcelerator Studio (not Titanium Studio) you can enable LiveView, which attaches a filesystem service to your project and pipes file changes at runtime, bypassing the build process. (aka hotloader, etc)
A) Turn on in Studio
B) Use the command line:
ti build -p ios —-liveview
Be sure you have the latest updates from Appcelerator to ensure parity with target compilers.
$ sudo npm install -g appcelerator
$ appc use latest
$ appc setup
If you don't have Appcelerator Studio, you could try third party solutions such as TiShadow:
$ sudo npm install -g tishadow
$ ti build -p ios --shadow
$ tishadow server
$ tishadow # run --shadow
The quickest development feature you can use is LiveView. In Appcelerator Studio, before you run the project you have a little eye icon in the toolbar to enable live view. Then Every change you save to your project will automatically refresh the emulator/device on which you are running.
You can also have a look at a project called TiShadow which basically does the same and is not related to the Studio.

Making a hybrid command line / GUI app in node-webkit

How would you make an app that if run normally (ie. double-click on the icon or whatever) would run as a GUI but would also have a headless mode if used with some command line switches?

Automate Xcode Simulator: how to build and launch an app from terminal

Is there a way to build an application for the iPhone, and have it running in the simulator, but using just the console?
I am trying to test an app, that will launch; send some data and then quit; if I run it via Xcode, it works fine; the simulator launch and everything is good.
But using xcodebuild; the app build but won't launch the simulator.
Is there any command or flag to do what Xcode IDE does, but using xcodebuild?
I have found an undocumented flag for the simulator, which is called "SimulateApplication", but sadly the usage is not documented; which makes it a bit hard to use.
Tried with ios-sim but my project won't work with it.
One way is to use instruments. In a way, you'll run it under "UI automation", but you don't actually automate the UI at all. The steps are:
Compile the app:
xcodebuild -sdk iphonesimulator7.1
Create a dummy UI automation script that does nothing (myscript.js):
while(true) {
UIATarget.localTarget().delay(100);
}
Then run the app via instruments:
instruments -t /Applications/Xcode.app/Contents/Applications/Instruments.app/Contents/PlugIns/AutomationInstrument.bundle/Contents/Resources/Automation.tracetemplate "$(pwd)/$(find . -name '*.app' | grep iphonesimulator)" -e UIASCRIPT myscript.js
(The find | grep monster there just translates to the full path of the compiled version of the app. You are of course free to type it manually as well if you so prefer.)