Search code examples
androidrobotframeworkandroid-uiautomator

Multiple devices connected error in Robotframework


I am using Robot Framework with UI-Automator for automating Native Android application. In my current instance I have connected two devices to my PC- one for my general testing work and in the second device, I am running Automation. I have given serial of the device while running the test cases.

But I am getting following error in the console:

EnvironmentError: Multiple devices attached but default android serial not set

can somebody help me what I need to do.


Solution

  • The answer is on the documentation for the Set Serial keyword, on uiautomatorlibrary.html, below:

    Set Serial android_serial

    Specify given android_serial device to perform test.

    You do not have to specify the device when there is only one device connects to the computer.

    When you need to use multiple devices, do not use this keyword to switch between devices in test execution.

    Using different library name when importing this library according to http://robotframework.googlecode.com/hg/doc/userguide/RobotFrameworkUserGuide.html?r=2.8.5.

    | Setting |..Value.| ..... Value ..... | . Value . |
    | Library | Mobile | WITH NAME | Mobile1 |
    | Library | Mobile | WITH NAME | Mobile1 |

    And set the serial to each library.
    | .... Test Case .... | ........ Action ........ | ..... Argument ..... |
    | Multiple Devices | Mobile1.Set Serial | device_1's serial |
    | .......................... | Mobile2.Set Serial | device_2's serial |