• How To Connect Mobile Device To Different OS

    In the previous article of this Appium tutorial series,  we have seen Installation of Appium Studio. Now in this article, we will learn How To Connect Mobile Device To Different OS.

    After we have the installation done, let’s now understand how can we actually connect our mobile devices to the different operating systems and commence testing.

    Even though this entire process of connecting a real android device is not dependant on the presence of Appium installed in your system, it is better to know more about Appium first and then start with the device connection.

    It is yet another very interesting part of the entire mobile automation testing lifecycle.

    Follow the steps carefully and you will be one step closer to the actual mobile automation testing.

    Connection of Android Devices with Windows

    In order to connect an android device to Windows, we need to meet certain prerequisites,

    • Java installed on the system(preferably Java version 8)
    • JAVA_HOME is set in environment variables
      The command to check: java -version
    • An android mobile device
    • Connecting cable
    • 200 MB to 1 GB of free space (this is required as the SDK folder is around 150 MB)

    Now, coming to the direct steps,

    Step 1: Download SDK tools or SDK manager

    Please visit the below link, but make sure to select the SDK tools to be downloaded.

    To get the SDK tools’ download link, search for the title “command line tools” for windows.

    https://developer.android.com/studio

    Step 2: Unzip folder & Extract platform-tools

    The downloaded file will be a zipped folder, hence you need to unzip the folder and extract the folder you decide.

    After you have unzipped and extracted the files, inside the tools folder, you won’t find the platform-tools, the ones that we exactly need.

    For this, we need the SDK manager which will be found as follows,

    Tools→ Bin folder → SDK Manager Batch file

    The SDK manager batch file will be used to download the platform-tools.

    Use the following command to get all the platform-tools extracted, based on your android version. Make sure you need to get the API version of the particular Android version that your mobile device is currently using. This API number is what is seen in the command.

    To use this command, go to the bin folder of the android-sdk tools, go to the address bar and erase the path by writing “cmd”.

    After you hit enter, it will open the command line in the same location.

    This is where you need to enter the command as follows,

    Don’t forget to accept the terms on the command prompt and allow the process of extraction.

    Step 3: Set environment variables

    We have to create two environment variables as below.

    You can right-click on ‘my computer’, go to properties, advanced system settings and you will find the environment variables.

    ANDROID_HOME = location of sdk folder

    Path : append the path of platform_tools folder

    Step 4: Check command adb devices on the command line

    In order to check the list of devices connected, use the following command,

    Adb stands for android debug bridge.

    Step 5: Make the device ready

    Before you connect the device through a USB cable, we need to do some settings.

    – enable developer mode

    To enable the developer mode in your device you have to follow simple steps,

    • Go to settings
    • Go to about phone
    • Inside about phone, you will see an option ‘build number’
    • You need to tap on this 7 times and by the 7th time, you will be a developer. Which is nothing but the developer mode will be enabled.

    Now when you go back to the settings, you will find the developer options, which you might not have seen before enabling the same.

    – make USB Debugging on

    To enable the USB debugging, you need to go to the developer option in the setting of your phone.

    Check for the option ‘USB debugging’. Enable the same and you are good to go.

    Step 6: Connect the device to the computer system through USB cable

    Now the time comes when you connect the mobile device to your computer. This can be done by using a USB cable.

    Step 7: Run command adb devices

    Now we will be able to connect the mobile device to the computer and to ensure the same, go to the command line and check the same by using the following command,

    Check your device id being displayed.

    Connection of Android Devices with iOS

    In order to connect an android device to iOS, we need to meet certain prerequisites,

    • Java installed on the system (preferably Java version 8)
    • JAVA_HOME is set in environment variables
      The command to check: java -version
    • An android mobile device
    • Connecting cable
    • 200 MB to 1 GB of free space (this is required as the SDK folder is around 150 MB)

    Now, coming to the direct steps,

    Step 1: Download android SDK

    Basically, there are two ways to accomplish the same,

    Way 1: Download it from https://developer.android.com/studio

    Way 2: The other way is through Brew,

    Either by entering the command,

    Or by using the command,

    After it has been downloaded or installed, we should be able to find it in the user local folder.

    Step 2: Extract the platform-tools folder

    Inside the tools folder, here as well, you won’t find the platform-tools, the ones that we exactly need.

    For this, we need the SDK manager which will be found as follows,

    Tools → Bin folder → SDK Manager Batch file

    The SDK manager batch file will be used to download the platform-tools.

    Use the following command to get all the platform-tools extracted, based on your android version.

    Make sure you need to get the API version of the particular Andriod version that your mobile device is currently using. This API number is what is seen in the command.

    To run this command you need to go to the command prompt, cd to the location where you have the bin folder.

    After this copy the below command and paste it. Once done, you will find the process of fetching the platform-tools.

    Step 3: Add environment variables

    We have to create two environment variables. This can either be cone with temporary set up or as a permanent one.

    Temporary set-up

    ANDROID_HOME = path of the android-sdk folder

    For doing this, we need to set PATH for ANDROID_HOME by using the below command

    Here /usr/local/share/android-sdk is the path to the folder.

    To confirm the same yourself, use echo $ANDROID_HOME in the command prompt.

    PATH: append the path of the platform-tools folder

    In order to add platform-tools to PATH, we will be using the below command,

    After this, we need to enter

    To confirm the same yourself, use echo $PATH in the command prompt.

    Permanent set-up

    Even though we have added the location to the environment variable, however the same was a temporary set-up. If you open a new session of the terminal, you won’t find the same setup.

    Hence, for this reason, we need to permanently set the paths in the bash profile which is present in the parent working directory.

    Use the following commands:

    Change current directory to parent working directory using — cd ~/

    Enter cat .bash_profile in the parent directory.

    If bash_profile does not exist, try using – touch .bash_profile

    Enter vi .bash_profile and press I on the keyword, so that you are in the insert mode.

    Now we need to add the followings paths,

    # Setting PATH for ANDROID_HOME

    export ANDROID_HOME=/usr/local/share/android-sdk

    # Adding platform-tools to PATH

    PATH=”/usr/local/Caskroom/android-sdk/4333796/platform-tools:${PATH}”

    Press Esc to come out of the window
    Enter:wq! And further click enter

    Following the above steps, the ANDROID HOME AND PATH will set permanently.
    Re-check the same by typing,
    echo $ANDROID_HOME
    echo $PATH

    Please be very careful while entering the correct location of the files.

    Step 4: Make a mobile device ready for automation

    Before you connect the device through a USB cable, we need to do some settings.

    – enable developer mode

    To enable the developer mode in your device you have to follow simple steps,

    5. Go to settings

    6. Go to about phone

    7. Inside about phone, you will see an option ‘build number’

    8. You need to tap on this 7 times and by the 7th time, you will be a developer. Which is nothing but the developer mode will be enabled.

    Now when you go back to the settings, you will find the developer options, which you might not have seen before enabling the same.

    – make USB Debugging on

    To enable the USB debugging, you need to go to the developer option in the setting of your phone. Check for the option ‘USB debugging’. Enable the same and you are good to go.

    Step 5: Connect the device with the computer system using a USB cable

    Now the time comes when you connect the mobile device to your computer. This can be done by using a USB cable.

    Step 6: Run command: adb devices

    Now we will be able to connect the mobile device to the computer and to ensure the same, go to the command line and check the same by using the following command,

    adb devices

    Check your device id is displayed.

    Sharing is caring.

    Share on facebook
    Facebook
    Share on twitter
    Twitter
    Share on linkedin
    LinkedIn

    Like This Post?

    We have a lot more where that came from?

    We only send really good stuff occasionally, promise.

    Rajkumar SM

    Leave a Comment

    Your email address will not be published. Required fields are marked *

    Share on facebook
    Share on google
    Share on twitter
    Share on linkedin
    Share on whatsapp

    Recent Posts:

    Scroll to Top
    API Testing eBook

    DOWNLOAD FOR FREE