This article explains how you can use the command-line interface (CLI) to create a DevTunnel session and connect to a device without using the Perfecto UI. For Android devices, it is also possible to create a single DevTunnel session and connect to multiple devices.
For this purpose, Perfecto offers the following tools:
- DevTunnelCLI.sh: Creates and connects a DevTunnel session with a device.
- DevTunnelCLISession.sh: Creates a DevTunnel session (without connecting to the device) and returns the session ID as output.
- DevTunnelMultiple.sh: Creates and connects a DevTunnel session with multiple Android devices.
- DevTunnelMultpleSession.sh: Creates a DevTunnel session (without connecting to the Android devices) and returns the session ID as output.
You can run these scripts on Windows and Mac. All scripts are available at https://github.com/PerfectoMobileDev/devtunnel-cli.
Expand a task to view its steps.
Before using the DevTunnel CLI, you need to perform the following steps to install DevTunnel.
To install DevTunnel:
- Open the Perfecto UI and navigate to the Manual Testing view.
- Open a mobile device.
- On the device toolbar, click the DevTunnel icon .
In the DevTunnel form, do the following:
- Click Download DevTunnelInstaller. The download tool identifies the target operating system and downloads the proper installation package.
- Open the file and follow the prompts on the screen. The installation is slightly different on Windows and Mac.
Note the default installation directory. You may change it if needed.
- When the installation is complete, click Close.
When establishing a connection with multiple devices, the security token provided is per MCM.
To make a security token available:
Go to https://github.com/PerfectoMobileDev/devtunnel-cli and download the following files to a dedicated folder:
The required script file
- Generate a security token:
In the Perfecto UI at
<YourCloud>.app.perfectomobile.com(where YourCloud is your actual cloud name, such as mobilecloud), click your user name and select My security token.
In the My security token form, click Generate Security Token.
Click Copy to clipboard. You will paste the token into a dedicated file in step 6.
- Click Close.
- Paste the security token into the
token.txtfile that you opened in step 2.
- Save and close the file.
Go to https://github.com/PerfectoMobileDev/devtunnel-cli and download the
Save it to the same folder as your
DeviceList.txtfile and add the IDs of the devices that you want to connect to, each device ID on a separate line.
Save and close the file.
Run the preferred script with the cloud name, device ID, and operating system parameters, as follows:Copy
./<script-name>.sh <cloud> <device id> <operating system>
<script-name>is the name of the script.
<cloud>is the short name of the cloud. For example, if your cloud was called
abc.app.perfectomobile.com, the short cloud name would be
<device id>is the ID of the device under test.
<operating system>is the name of the operating system.
Device IDparameter is not required.
When you are done working with the device, close the DevTunnel session by doing one of the following.
If you are running the
DevTunnelMultiple.sh, stopping the script ends all connections it has made.
From another command line window opened in the same directory, run the following command:CopyOn Mac
touch stopnowCopyOn Windows
type nul > stopnow
Run the script in the background and run the following command from the same command line window:CopyOn Mac
touch stopnowCopyOn Windows
type nul > stopnow
If you close the command line window that runs the script without properly stopping the script, the DevTunnel session stays connected and the device or devices remain in use. In this case, you can manually clean up by running the provided cleanup scripts. The following scripts are available at https://github.com/PerfectoMobileDev/devtunnel-cli:
DevTunnelCLICleanup.sh: Use for a DevTunnel session that is connected to a device. This script disconnects DevTunnel before stopping the device session.
DevlTunnelCLISessionCleanup.sh: Use for a DevTunnel session that is not connected to a device
To clean up:
Run the respective cleanup script with the cloud name as the only parameter, as follows:Copy
If one or more devices fail to connect, the failure may be:
The script. If this is the case, the error is displayed in the terminal window, and other devices will likely continue to connect without any problems. Make sure the device IDs, cloud identifier, and security token are correct.
The DevTunnel process. If this is the case, the error is included in the log file. Inspect the DevTunnel log file for indications of the problem.
On Windows: (default location)
C:\Program Files (x86)\DevTunnel\devtunnelhelper.log
Contact Perfecto Support.