Using Instruments to launch automation tests via SSH - ios

I'm currently trying to run iOS mobile functional tests from a CI server. Just so you know I'm using the Calabash framework but my problem is related to Instruments : Instruments doesn't launch the requested device.
When I use Instruments directly from the terminal on the server, everything goes fine (Instruments -w "iPhone 5s (8.1 Simulator)" for example). I get the following message :
Waiting for device to boot...
Instruments Usage Error : No template (-t) specified
instruments, version 6.1 (56160)
usage: instruments [-t template] [-D document] [-l timeLimit] [-i #] [-w > device] [[-p pid] | [application [-e variable value] [argument ...]]]*
However when I launch the same command from an SSH connection, it ignores the requested device and launches the device previously used. And this time it stays stuck at Waiting for device to boot...
Does anyone have an idea that could explain this behaviour ? Why would it work from a local session and not from a remote ssh connection, and how to fix it ?
I have Instruments in version 6.1, on OS X Yosemite.
Thank you.

Good question, I know that if the process being run is considered a background or system task it won't be able to launch instruments and run the test since it requires user level runtime status. I discovered this when trying to launch instruments from a cron job. When you ssh your shell thread may be considered system level. My only suggestion would be to put your commands in a shell script, and somehow call the script on a user-level thread. Unfortunately I am not a unix expert and cannot give you the specifics of how to do that, hope this helps.

Ran into the same thing. If you use Jenkins as your CI server, connecting your slave using JNLP Web Start instead of SSH will allow instruments to work as expected. Not an ideal solution for all configurations, but it does the trick.

Related

Appium Parallel execution (Emulator and real device)

Iam automating an android app. I would like to know is there a way to run the tests parallely between emulator and a real device at the same time? Could you help me with the process? When i do adb devices, i see it recognizes "emulator-5554" and not the name that i gave while setting up the emulator.
First run command to get list of emulators are running
adb devices
enter image description here
in above image emulator-5554 and emulator-5556 are udid
Now, if you want to run parallel test in both devices, you need to start 2 appium servers as below with unique port and bootstarp port
first go to the directory where main.js is available using command line, and type below command to run 2 appium servers respectively
appium -p 1901 -U emulator-5554 -bp 2345
(This will open one appium server and it will return URI:0.0.0.0:1901
Now start another appium
appium -p 1902 -U emulator-5556 -bp 2345
(This will open another appium server and it will return URI:0.0.0.0:1902
Now, you are set and you can use both URL in different test and execute your TestNG

How to run ios simulator for ui Automation test on jenkins

I'm trying to run a UI Automation script from jenkins :
instruments -w 'iPhone 6 (8.1 Simulator)' \
-t '/Applications/Xcode.app/Contents/Applications/Instruments.app/Contents/PlugIns/AutomationInstrument.xrplugin/Contents/Resources/Automation.tracetemplate' \
'myAppName' \
-e UIASCRIPT 'some_path' \
-e UIARESULTSPATH 'some_other_path'
But I'm getting an error and the simulator won't start
Waiting for device to boot...
2015-03-18 10:29:04.064 instruments[13082:64124] [MT] iPhoneSimulator: Could not launch simulator: -10810
I does work when running from the command line under the jenkins user.
Any Help would be much appreciated, thanks.
It's probably related to the fact, that you're not running your Jenkins master or Jenkins slave in a desktop session, meaning that it does not have access to your GUI (e.g. it can't launch anything that pops-up a window or a dialog).
So you either need to start the Jenkins master manually or allow it to access the GUI if it's run as a service (not sure how to do this on Mac OS). Another way would be to run a Jenkins slave on the same machine, started via JNLP.
The following Stackoverflow issues deal with the same error message/code and suggest similar solutions:
Timed out waiting 120 seconds for simulator to boot
Launching XCode Simulator with jenkins user

Can Jenkins start up GenyMotion on Ubuntu 14, if I access the Jenkins website from my Mac?

Is it possible for this setting to work?
1) Ubuntu 14 with Jenkins, Genymotion, and Virtual Box installed
2) The job inside Jenkins will restore and run Genymotion from a command line following this tutorial: http://blog.genymobile.com/genymotion-jenkins-android-testing/
From my Mac, I tried to access the Jenkins website and run the build.
Firstly, Genymotion failed because it couldn't "connect to X server".
So, I installed Xvnc Plugin on Jenkins which solved the error.
Unfortunately, Genymotion still failed to start up with the error "Cannot get IP address".
Please note that I only have "ssh -X" access to the server.
I can manually start up Genymotion but the process was terminated when I logged off. As a result, I could not leave the GenyMotion run on the Server as suggested by this solution: Jenkins - Use Genymotion VM instead of Android Emulator
Any advice?
Here is the way to make Genymotion works on a continuous integration server.
First, the computer running Genymotion needs to respect the hardware requirements
You won't be able to run Genymotion if you don't have an X server running.
I don't think xVNC supports OpenGL so I advise you to run your standard X server.
You can launch the Xorg server by running startx.
Then you need to set your ssh connection in Jenkins without the -X parameter because we want the rendering to be done locally
Then you need to declare the environement variable DISPLAY to the default X client's value. Most of the time it is :0
This value will ask to open all the windows you launch through the ssh connexion into the first X client. It is the one running on the computer screen.
To check the DISPLAY value you need to enter, you need to access the computer physically and type echo $DISPLAY. Most of the time this value is :0
Also, if your computer is not compatible with the hardware requirements, you can use another computer on your network to run your tests thanks to the Jenkins nodes. Here is a good tutorial to set it up.
And finally, I want to mention we will soon release a command line tool for Genymotion and a Gradle Plugin that will allows you to control your Genymotion devices running during your tests directly from your build.gradle file.
It`s a bit late, but maybe this could help you out
### Get IP address of selected VM
VM_IP=`VBoxManage guestproperty get $VM_SELECTED androvm_ip_management | awk - F ": " '{print $2}'`
I found this here (repo) respectively here (slides)

TeamCity fails to run iOS appium tests when auto-launched

Description
We are using appium in our cucumber suite within TeamCity 8 on an Apple MacMini running Mavericks. The problem is that appium seems to fail to interact with the iOS Simulator when it is ran from TeamCity at login (via Automator).
The only combination that I have found to work is to run the following from the Terminal in an interactive session:
sh /Applications/buildagent/bin/agent.sh start
What does not work?
running agent.sh start from an ssh session
creating a shell script with Automator that launches at login (the macmini is set to login automatically)
Theory
My theory is that it has something to do with Preferences -> Security & Privacy -> Accessibility. The only way that it works when launching from Terminal is if Terminal is added to this list of allowed applications. I'm not sure what I need to add to this list in order for this to work automatically at login.
Any help would be greatly appreciated.
Many iOS tests will not run without an interactive session. For example, unit tests using the iOS simulator will not work.
Edit: By interactive session, I mean the TeamCity agent must be started from the desktop, not via an SSH session. Otherwise nothing can communicate with the Simulator.
You are correct, you need to allow Appium to interact with Automator.
Solutions straight from the documentation:
If you're running Appium from an NPM install: sudo authorize_ios
If you're running Appium from source: sudo grunt authorize
If you are running Appium.app, you can authorize iOS through the GUI. This prompt pops up the first time you click "Launch/Run" on the GUI and it tries to open the simulator

BB10 start applications from command line

I've followed the instructions here:
BB10 Cascades Command Line Development
Now I've got a makefile project, which can compile and deploy my application to a connected device. The only problem is, I can't start the application remotely. I've created a special test version, which simply runs an automated test and then quits, so the next logical step would be starting the application, and waiting for it to exit (it would be great if I could monitor stdout and stderr) or kill it if it takes too long.
What I'm trying to accomplish (to avoid the xy problem) is the integration with a Jenkins server we already use for other platforms. E.g.: on Android we use robotium to achieve the same degree of integration.
blackberry-nativepackager allows you to launch the application similar to androids adb.
Just call it like
blackberry-nativepackager -launchApp <path to bar file> -device <devices ip address> -password <your pwd>

Resources