Appium Parallel execution (Emulator and real device) - appium

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

Related

I am using appium.app on mac how to open more than one session to run with different ports

I want to run the appium with different ports i am using appium.app on mac desktop.how to run with different ports any ideas..?
What do you mean to run appium with different ports? In case you're using the app, you set the port before you start the server.
In case you meant to run multiple appium sessions with different ports, I've installed appium using npm and then started my servers from command line
I guess you are talking about attaching more than one device and then executing the scripts in parallel on all devices like the selenium grid.
You can go through this link, which is appum's official documentation for setting up selenium grid for mobile automation.

Opening multiple appium server Instances on same machine

Can I start 2 appium server instances on my machine at the same time so that I can execute my test script simultaneously on 2 different devices connected to the machine?
Actually what I'm trying is to run my test script on 2 devices connected to same windows machine. For this I am using TestNG to pass the Android Driver url to start session. This url will be dynamic as 2 devices will be using 2 Appium server instances. Can I create 2 instances of Appium server at same time? If so then can I use code to create those instances as I don't want to use GUI to start it.
This question has already been asked and answer (if I am reading what you want correctly).
Please refer to How to start the Appium server from command prompt in MAC machine?
On a windows machine there should be an appium executable which you run with the command line arguments --address 127.0.0.1 -p 4273
In essence all you need to do is use a different port for your tests.

How to start emulator on remote machine by using command line

I have created emulator on remote machine (IP: 192.168.X.X) and that is working fine. After that I created Jenkins Job to execute Appium Test. I need to launch Emulator on remote machine (IP: 192.168.X.X) through Jenkins window batch commend.
See Windows Sysinternals' PsExec:
PsExec is a light-weight telnet-replacement that lets you execute processes on other systems, ...
Usage: psexec [\\computer[,computer2[,...] | #file]][-u user [-p psswd][-n s][-r servicename][-h][-l][-s|-e][-x][-i [session]][-c [-f|-v]][-w directory][-d][-<priority>][-a n,n,...] cmd [arguments]
I created a batch file that contain cmd command to execute Emulator and execute that batch file.
CMD command to invoke emulator
emulator -avd 'Emulator Name'
Emulator name you can get from command -> adb devices

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

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

Resources