Associate a device with a Perfecto Connect tunnel
Use Perfecto Connect to route device traffic through a secure tunnel so that real devices, virtual devices, and web sessions can access internal or restricted environments. After you start a tunnel and obtain its tunnel ID, you can associate a device with that tunnel in the Manual Testing view, Scriptless Mobile, or an automation script.
On this page:
Prerequisites
-
Perfecto Connect installed on your computer
-
A running tunnel with a valid tunnel ID
-
Appropriate permissions to access devices or web sessions in Perfecto
Associate a device in the Manual Testing view
In the Manual Testing view, perform the following steps:
- Start Perfecto Connect on your workstation and copy the tunnel ID.
- In Perfecto, open the Manual Testing view.
-
In the header area, click the Perfecto Connect button
. -
Select the required tunnel ID.
-
Open the required device or Web session.
When Perfecto Connect is turned on, the session automatically routes traffic through the tunnel.
Associate a device in Scriptless Mobile
- Start Perfecto Connect on your workstation and copy the tunnel ID.
- In Perfecto, open Scriptless Mobile.
-
In the header area, click the Perfecto Connect button
. -
Select the required tunnel ID.
-
Open the required device or web session.
When Perfecto Connect is turned on, the session automatically routes traffic through the tunnel.
Associate a device in an automation script
To associate a device programmatically, you must:
-
Pass the tunnel ID as a capability when creating the session.
-
Attach the device to the tunnel using the
perfectoconnect.attach(tunnelID)after the driver/session is created. - Detach at the end of th etest using
perfectoconnect.detach(tunnelID).
All device traffic (HTTP/S requests and responses) is then routed through the specified tunnel for the duration of the session.
Capabilities for automation
When using Perfecto Connect in Selenium or Appium scripts, set the following capabilities:
Required:
-
securityToken: Used to authenticate the session -
deviceName: ID of the device to open -
tunnelId: Associates the session with the active Perfecto Connect tunnel
Optional:
-
automationName: Required when using Appium (for example, "Appium") -
perfectoconnect: Used only for legacy attach/detach workflows. Use only if required in your automation environment
Automation example (Java)
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("securityToken", "YOUR-SECURITY-TOKEN");
capabilities.setCapability("deviceName", "YOUR-DEVICE-ID");
capabilities.setCapability("tunnelId", "YOUR-TUNNEL-ID");
AndroidDriver driver = new AndroidDriver(new URL("https://<your-cloud>/nexperience/perfectomobile/wd/hub"), capabilities);
// REQUIRED: attach the session to the tunnel
perfectoconnect.attach("YOUR-TUNNEL-ID");
// ... run your test steps here ...
// REQUIRED: detach from the tunnel before quitting
perfectoconnect.detach("YOUR-TUNNEL-ID");
driver.quit();
tunnelId capability.
Associate a device in the legacy UI (Interactive mode)
If you are working in the legacy Interactive mode:
- Start Perfecto Connect on your workstation and copy the tunnel ID.
- In the legacy UI, launch the device to connect.
- Click the P.Connect function icon.
- Copy the
tunnelIDfrom theperfectoconnectclient and paste it into the Perfecto Connect - Enter Tunnel ID dialog box. - Click Connect Device.
Disconnect a device from a tunnel
You can disconnect a device from a tunnel either through the Perfecto UI or programmatically in automation scripts.
-
Manual Testing and Scriptless Mobile: Click the Perfecto Connect button to turn off the tunnel. The device disconnects when the tunnel is stopped.
-
Automation: Call
perfectoconnect.detach(tunnelId)before closing the driver (for example,driver.quit()).