The Sauce Labs Cookbook

Sauce Headless

Front End Performance Testing


External Resources

More Info

Page tree
Skip to end of metadata
Go to start of metadata

Virtual USB for Real Devices simulates connecting a real device with a USB cable directly to your local machine during a live or automated testing session.  Virtual USB lets you interact directly with a device in the Sauce Labs cloud via an integrated development environment like Android Studio and Xcode, or browser-based tools like Chrome DevTools and Safari Web Inspector. You may also use homegrown developing and testing tools because Virtual USB integrates into the development environment as if the device was directly connected to the workstation. When you debug your applications, Virtual USB provides the ability to build and deploy an application directly from the IDE. You may also directly monitor device performance metrics such as CPU consumption, device memory, and network data performance.


  • This feature is available only on Private devices
  • For Android, make sure you're using an ADB version that is above 1.0.39

Legacy Client Instructions

The information in this topic is for our latest Virtual USB Client release: v1.7.1. If you have a legacy version of the client (v.1.0 - v.1.2), check out Using Early Versions of Sauce Labs Virtual USB

Download the latest Virtual USB Client

Virtual USB Client 1.7.1 (2020-01-16)

Android Virtual USB

Android Virtual USB change log

Click here to see the change log of the Android Virtual USB client

iOS Virtual USB

Beta note

Virtual USB for iOS Devices is in beta, contact your Customer Success Manager to get access.

iOS Virtual USB change log

Click here to see the change log of the iOS Virtual USB client

Known Limitations

  • Xcode/Safari has to be closed before connecting to an iOS Virtual USB session (or relaunch it after connecting). Otherwise, the device won't show up.
  • Devices attached to the host locally are not useable while using iOS Virtual USB. When the server is shut down, it asks again for permissions to put the original `/var/run/usbmuxd` socket back into its place, and Xcode/Safari have to be re-launched to show the local devices.

Launch and Connect Virtual USB to a Real Android Device Live Testing Session

Accessing Instructions in the Client

You can also find instructions for using the Virtual USB client by running java -jar vusb-client.jar --help.

  1. Download and install the Virtual USB for Live Testing client to the same machine where you have Android Studio installed. Java is required to run Virtual USB.

  2. Get your User API key from the Account Settings menu in the Sauce Labs Real Device Cloud web interface. 

    Finding Your Real Device API Key

    This is not the same as your project API key, and is specific to your Sauce Labs account.

  3. From a command line, launch the client. You will have to choose between the EU or the US datacenter, depending on which device you are trying to connect to:

    java -jar vusb-client.jar server --datacenter <EU/US>
    java -jar vusb-client.jar server --datacenter EU
  4. Once the server is open, you can now start a session. From another command line window, launch the client again using this command to create a new session:

    java -jar vusb-client.jar startSession --apiKey <API_KEY> --deviceName <DEVICE_NAME>
    java -jar vusb-client.jar startSession --apiKey 37D274BC3A65A34BB3DA4DDF7B77E341 --deviceName Motorola_Moto_Z_real

    Static Allocation

    This will allow you to allocate a device for your session, that means the device will be in use and not available for other uses until your session is over.

  5. When Virtual USB connects to your live testing session, it will return a success message and a link to watch the device running your test in real time. 

    Example of success message
    37D274BC3A65A34BB3DA4DDF7B77E341		Motorola Moto Z		ANDROID		7.0
    localhost:7000	online
  6. Copy the port number and use it to connect adb to your session device using Virtual USB.

    adb connect localhost:<paste returned port here>

    adb connect localhost:7000

  7. At this point vUSB is fully connected and you can use Android Studio (or Google Chrome's Remote Debugging)  to debug your app, execute automation based on adb - or any other tool that is adb compliant. For example, using adb shell, you can start the camera of the connected device:

    adb shell
    am start -a

Closing a Virtual USB connection

  1. Make sure you disconnect your device from ADB using adb disconnect <IPAddress>:<portNumber>

    adb disconnect localhost:7000
  2. If open, close your SauceLabs device view in your browser.

Unsupported ADB commands

These ADB Commands are not supported for use with Sauce Labs Virtual USB

  • adb-reverse