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.

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:

  1. Start Perfecto Connect on your workstation and copy the tunnel ID.
  2. In Perfecto, open the Manual Testing view.
  3. In the header area, click the Perfecto Connect button .

  4. Select the required tunnel ID.

  5. 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

  1. Start Perfecto Connect on your workstation and copy the tunnel ID.
  2. In Perfecto, open Scriptless Mobile.
  3. In the header area, click the Perfecto Connect button .

  4. Select the required tunnel ID.

  5. 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:

  1. Pass the tunnel ID as a capability when creating the session.

  2. Attach the device to the tunnel using the perfectoconnect.attach(tunnelID) after the driver/session is created.

  3. 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)

Copy
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();
Perfecto Connect for fast web devices is supported only with Selenium scripts. The script must supply the tunnel ID using the tunnelId capability.

Associate a device in the legacy UI (Interactive mode)

If you are working in the legacy Interactive mode:

  1. Start Perfecto Connect on your workstation and copy the tunnel ID.
  2. In the legacy UI, launch the device to connect.
  3. Click the P.Connect function icon.
  4. Copy the tunnelID from the perfectoconnect client and paste it into the Perfecto Connect - Enter Tunnel ID dialog box.
  5. 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()).

Related topics