AndroidManager - module for managing android emulators



  • Name: AndroidManager
    Version: 2.5
    Data: AndroidManager.zip
    Source: AndroidManager2.5.xml
    Do you agree to include your module in BAS: Yes
    Changelog:

    Screenshot_2.png

    The module allows to automate popular actions on Android-based mobile emulators. It uses appium server with uiautomator2 driver and the package webdriverio for connection to it.


    Module features:

    • Multithreading due to asynchrony. Works faster than most similar open-source libraries with classical multithreading.
    • The ability to search for elements by xpath rather than a set of attributes.
    • All popular adb commands have been added, as well as actions that are not in appium or webdriverio.

    Installation Instructions

    1. Download and install Java jdk. You need to choose the Windows x64 Installer version and jdk, not jre and others. The file is currently named jdk-8u341-windows-x64.exe.
    2. Right click on "My Computer" > "Advanced System Settings" > "Environment Variables". In the lower window (system variables), click "Create" and write the name of the variable JAVA_HOME, and in the value specify the path to the installed Java in the previous step.
      Screenshot_2.png
    3. Download and install Android Studio.
    4. Run Android Studio and press More actions.
      Screenshot_3.png
    5. Choose SDK Manager.
      Screenshot_4.png
    6. Go to SDK Tools tab and install Build-Tools and Platform-Tools as shown in the screenshot. If you plan to connect real phones, you must also install the Google USB Driver and Google Web Driver.
      Screenshot_5.png
    7. Go back to "Environment Variables" (see point 2). In the user's environment variables (top window), click "Create" and set the variable ANDROID_HOME, the value of which is to specify the path to the SDK folder.
      Screenshot_6.png
    8. Find the Path variable in the lower window, select it and click "Change".
      Screenshot_7.png
    9. Add paths to bin folder at jdk path, SDK/platform-tools and SDK/build-tools folders.
      Screenshot_2.png
    10. Download and install Node JS. After installation, Node will prompt you to restart the PC. Agree and restart.
    11. Install appium:
    npm install -g appium
    
    1. Install appium-doctor:
    npm install -g appium-doctor
    
    1. Run appium-doctor with --android flag to check that all dependencies are correctly installed on the system.
    appium-doctor --android
    

    The items marked on the screen should also be green.
    Screenshot_9.png

    If emulators (Nox, MEmu, etc.) were already installed in the system at the time of performing the steps from this instruction, then they often have their own adb.exe files, which are also registered in environment variables. In this case, one of these files will be used when connecting, and not adb from the SDK.

    To fix it, just rename the adb files in the folder with the emulator, for example, to _adb.exe.

    To check the location of adb files in the system, you need to download the utility gow.exe. Restart your PC after installation.

    After that, you can run the command:

    where adb
    

    It will show the paths to the adb files that the system sees. The first path should lead to the SDK folder and be something like this:

    C:\Users\username\AppData\Local\Android\Sdk\platform-tools\adb.exe
    

    Startup Instructions

    To interact with emulators, you need to run the appium server. This can be done automatically through the module using the action "Start Server". However, webdriverio library often does not see the server started in this way. Therefore, it is highly recommended to start appium server manually before starting your BAS script. This is done with the command:

    appium -a 127.0.0.1 -p 4723
    

    where 127.0.0.1 - IP where the server is running, 4723 - port.

    If the server has started, you will see something like this output:
    Screenshot_11.png

    The console window must be left open for the duration of the BAS script. To stop the server, press Ctrl+C in the console.

    It is recommended to run appium on the default port 4723. Because another random port may already be occupied by some system process.


    Sample of Template

    The script that sets proxies on emulators and allows to turn on the proxy if it is turned off through the Drony app: Drony.xml


    Donate for the beer :)

    The module is developed and maintained completely free of charge. At the same time, it takes a lot of time and effort. You can support the project by sending any donation. This will greatly help in its further development and implementation of new functionality. Requisites are into the spoiler.



  • Come on, support you to improve the program



  • good start :)
    alt text



  • @shashou520 I'm afraid there is no point in improving. I looked at the issue with multithreading, it looks like the problem is on the library side and is related to the ports on which the server is running.

    Therefore, I see no reason to improve software that works in 1 thread. Perhaps in the future I will try to write a server, but this is not certain. ;)

    If anyone knows a node package with no issues - let me know and I'll rewrite on it. As exampe here is python module which I use for automation. But I didn't see any its implementations on node js.



  • @thepappo said in AndroidManager - module for managing android emulators:

    Android SDK tools

    hi when multi-tread will work?



  • @becko8011 I have some ideas how to fix that. I plan to completely abandon the use of Node library and replace its methods with adb and uiautomator CLI API calls. When it will be ready, I can't say. I do this in my free time.



  • thanks Look forward to your perfect improvement of the module



  • Hello thanks for module

    Im having issues installing this module any help ?

    https://prnt.sc/dgM9a2QALyQg
    https://prnt.sc/EXgxPMcK22x_



  • @boliotrmezemer hello, the screenshots won't open.



  • Hello was really looking for this.

    Can u by any chance make a video how to setup this for the newbies for example how to connect with the android device , i smh cant figure that out.

    Is there anything required to install in bas to be installed for it to work. Thanks!



  • @hetznerrdps hello, you can check manual from the start post that contains info about preparing your PC to work with emulators. Also see an example of BAS template there.



  • BAS KHÔNG CHUYÊN DỤNG ĐỂ LÀM VIỆC NÀY, TẠI SAO PHẢI CỐ GẮNG




  • Version 2.0

    The main change in this version is the move to Appium, which uses the uiautomator2 driver to send commands to emulators. Appium is used for all actions related to interacting with elements via xpath, as well as for the actions "Connect to Device" (a session is created for the specified device by serial number on the server), "Disconnect from Device", "Take Screenshot", "Open Notifications Panel" and "Get XML dump".

    Due to the use of appium, multithreading is now working.

    Other changes:

    1. Node js has been updated to version 18.10.0.
    2. Removed actions:
    • "Device Info" - there is no method for this action in the appium, and it is not clear what device settings need to be collected.
    1. Added actions:
    • "Start Server";
    • "Stop Server";
    • "Is App Installed";
    • "Is App Running";
    • "Open Notifications Panel".
    1. Changed action settings:
    • "Connect to Device" - all fields except "Serial number" have been removed. Added "Set up device" selector;
    • "Take Screenshot" - removed the fields "Image quality" and "Save method on device" (appium does not allow to choose the quality and the folder for saving on the device itself).

    For the following actions, the "Number of steps" parameter has been changed to "Duration, ms":

    • "Long Click by Xpath";
    • "Long Click by Coordinates";
    • "Swipe on Screen".
    1. Fixed a bug in the "Scroll to Element" action. If "to the left" or "to the right" was selected in the scroll direction, then the scroll was performed down.
    2. Timeouts are now passed to Node js from the settings for actions that require a wait.

    Please see the detailed instructions for installing the environment and launching the module in the first post.




  • Version 2.1

    Fixed a bug in the "Get Current Activity" action. App name was saved in the result instead of activity.



  • Is there any documentation on how to use it? How to open/install apps, etc? Maybe Sample BAS file?



  • @ChrisHolmes said in AndroidManager - module for managing android emulators:

    Maybe Sample BAS file?

    The sample is in the first post



  • @thepappo where? Can't see it





  • Hello, thank you so much for this module. One question.
    how can I get a device list?



  • @wakid48219 are you joking? :) The name of the first action is "Get Devices List".



  • Can anyone help me make it work?

    f2790f24-2809-4ef7-b767-3f46d24a6a22-image.png


Log in to reply