Search code examples
robotframeworkappium-android

Appium script on an already launched app


I am automating android app tests with Appium, and I need to split my test script in half while the app is still running.

The first script initiates a log into the app, and the next script achieves it. Therefore the second script must get the app in the exact same state as it was left by the first step. The app cannot be closed meanwhile.

Is there a way to do this, and if there is, how? Thank you!


Solution

  • This is quite simple.

    Create your test suite directory and insert Initialization file into it.

    In the Initialization file do the following setup:

    Suite Setup       Open Application
    Suite Teardown    Close All Apps
    

    Then then in the scripts in this directory do not Open Application, just add your Appium keywords and those will use the current open application.

    I use this when I need to do something in iOS application (AppiumLibrary), then do operation over same data on web client (SeleniumLibrary) and then finish in iOS and finally check in web client/database.

    The file structure is something like this:

    __init__.robot
    01_login_appium.robot
    02_do_appium_stuff1.robot
    03_do_selenium_stuff1.robot
    04_do_appium_stuff2.robot
    ...
    

    Alternatively if you just want to have separate script for logging to reuse in scripts, I prefer to create keyword resource file for setup, logging or other common tasks where I would encapsulate several steps in such keyword and reuse it in setup for different scripts.