Configuring Mobile Device With System In Appium

By Vijay

By Vijay

I'm Vijay, and I've been working on this blog for the past 20+ years! I’ve been in the IT industry for more than 20 years now. I completed my graduation in B.E. Computer Science from a reputed Pune university and then started my career in…

Learn about our editorial policies.
Updated March 7, 2024

This Tutorial Explains how to Connect a Mobile Device with PC and Configure it for Automation Testing Using Appium. It covers the Verification of Mobile by ADB:

We have to connect a real-time Android device with the PC in order to automate Android application tests in the Android device using Appium.

For test cases to run on devices, we need to ensure that :

  • USB Debugging mode is enabled on the mobile device.
  • ADB recognizes the device connected to the system.
  • Changing the Desired capability as per the device/application.

=> Check ALL Appium Tutorials Here.

Configure Mobile Device With System In Appium

Configure Mobile Device With System In Appium

Here is a Video Tutorial:

Enable USB Debugging Mode In Mobile Device

This can be done in 2 ways.

  1. Enable USB debugging mode in settings of Mobile devices.
  2. Activate USB mode through PDANET+ software.

#1) Developer Options

  1. Navigate to the Settings app on the phone.
  2. Scroll down and click on the Developer Options.
  3. Turn on the Developer Options and click the USB Debugging.

Some devices do not have “Developer Options” under Settings. In such cases, follow the below steps:

  1. Navigate to Settings > About Phone > Build Number.
  2. Dab on Build number 7 times, then a pop up will appear saying ‘You are now a developer’.
  3. Then Go back to settings. You will find ‘Developer Options’ getting listed.
  4. Enable ‘USB Debugging’ and now the device is ready to connect to the system.
  5. Once done, you will now be able to enable/disable it whenever you desire by going to Settings -> Developer Options -> Debugging -> USB debugging.

#2) Using PDANET+

  1. Install PDANet+ from PlayStore.
  2. Open the application and select ‘Activate USB Mode’.
  3. Once the USB mode is selected, your device is ready to be connected to the system

Also, make sure to have PDANet+ installed in the system when you try to enable USB debugging mode in the mobile devices through PDANet+ app.

DOWNLOAD PDANet+ In System

  • Go to PDANet+ DOWNLOAD PAGE.

PDANet+ DOWNLOAD PAGE.

  • Click on the download link as shown in the above image. It will download the installation file.

Installation Of PDANet+ In System

  • Connect your Android phone with PC with USB debugging mode enabled.
  • Double click on PDANet+ installation .exe file.
  • It will open the PDANet+ installation dialog.
  • Proceed for installation with default selected options and settings on each screen of installation dialog.

You can choose either one of the options (through Settings or through PDANet+ app) mentioned to enable USB debugging mode. Once the USB mode is enabled, connect the device to the system using the USB cable.

Verify If System Recognizes A Device Using ADB

To verify if the system is able to recognize the device,

  • Open command prompt
  • Type >‘adb devices’
  • Click on Enter.

The device name should be listed in its response as below. In this case, only one device is attached, so the device name of that mobile is listed as ‘AVY9KA90322022030’.

This command displays all devices connected to the system at that instance (might one or two or more devices also).

Note: We need to make sure that the Android SDK is installed in the system and its environment path is set, before running the ADB command.

If the device is not displayed in the response, then there might be some issue with device connection or sometimes USB debugging mode may not be enabled properly.

device name of that mobile is listed

Desired Capabilities

Desired Capabilities is a JSON object (which is a set of key-value pairs) sent by the client libraries to the Appium server.

Desired Capabilities is a class in Selenium and is used to store properties of devices and applications. These properties are read by Appium at run time and recognize the device and application for automation. We need to import “import org.openqa.Selenium.remote. DesiredCapabilities” library file and add it to the project in order to work with the Desired Capabilities.

In order to ensure automation on the mobile device connected, we mention the device name in the Desired Capabilities and Appium uses it during execution in order to find the device and automate it.

Now, let us have a look at the major capabilities used for Automation.

CapabilityFunction/Explanation
platformNameIt is used to set the mobile OS platform. We can pass values as iOS, Android, or FirefoxOS:
caps.setCapability("platformName","Android");
The below command can also be used : caps.setCapability(MobileCapabilityType.PLATFORM_NAME, "Android");
platformVersionTo set the mobile OS version,
for example, use the following command: caps.setCapability("platformVersion","5.6");
The below command can also be used: caps.setCapability(MobileCapabilityType.PLATFORM_VERSION, "5.6");
deviceNameWe can define the type of mobile device or emulator to use, using the following command,
for example :
caps.setCapability("deviceName", " AVY9KA90322022030’");
You can use the following command as well: caps.setCapability(MobileCapabilityType.DEVICE_NAME," AVY9KA90322022030’");
(Device name is obtained when we type ‘adb devices)
appPackageThis capability is for the Java package of the Android app that you want to run,
for example, com.android.calculator2 for calculator, com.android.settings to Open Settings app, and so on:
caps.setCapability("appPackage", "com.android.calculator2");
Alternatively, you can use this command: caps.setCapability(MobileCapabilityType.APP_PACKAGE, "com.android.calculator
(we will discuss in detail in the next section on how to get appPackage name from device)
appActivityBy using this capability, you can specify the Android activity that you want to launch from your package,
for example, MainActivity, .Settings, com.android.calculator2.Calculator, and so on:
caps.setCapability("appActivity", "com.android.calculator2.Calculator");
You can also use the following command: caps.setCapability(MobileCapabilityType.APP_ACTIVITY, "com.android.calculator
(we will discuss in detail in the next section on how to get appActivity name from device)
browserNameIf you want to automate mobile web applications, then you have to use this capability to define the browser.
For Safari on iOS, you can use this: caps.setCapability("browserName", "Safari");
Also, you can use the following command: caps.setCapability(MobileCapabilityType.BROWSER_NAME, "Safari");
For Chrome on Android, you can use this: caps.setCapability("browserName", "Chrome");
Alternatively, you can use the following command: caps.setCapability(MobileCapabilityType.BROWSER_NAME, "Chrome");

Conclusion

Thus we have seen the method of configuring mobile devices with systems in Appium, the ways of enabling USB debugging mode in mobile devices as well as installation of PDANet+ in the system.

Our upcoming tutorial will explain how to automate applications on a real-time mobile device using Appium.

PREV Tutorial | NEXT Tutorial

Was this helpful?

Thanks for your feedback!

Leave a Comment