Handling USB Popup in Appium Automation
  • 18 May 2023
  • 1 Minute to read
  • Dark
    Light

Handling USB Popup in Appium Automation

  • Dark
    Light

Article Summary

Overview

Many times when users connect a phone to their laptop or desktop to run tests, it shows an option to enable the USB Debugging. Most times this causes an inconveince, as you would need to enable the USB Debbuging to continue to perform different app tests.

Issue

Sometimes automation scripts fail as this option needs to be validated manually. But thanks to these new steps, you can simply add a few lines of code to your script for the USB Debugging Popup to get validated and move on to the crux of the app testing tasks.

image.png

Resolution

You will need to include the code below in your automation scripts after driver initialization to avoid the USB pop up

//To press Homekey
KeyEvent KEYCODE_HOME = null;
((AndroidDriver) driver).pressKey(KEYCODE_HOME);

//To relaunch the app
((InteractsWithApps) driver).activateApp("com.pcloudy.appiumdemo");

Was this article helpful?