robotframework-appiumlibrary

repository·master·Indexed 19 days ago

https://github.com/serhatbolsu/robotframework-appiumlibrary

A Robot Framework library for automated mobile app testing of Android and iOS applications using Appium. It acts as a bridge between Robot Framework keywords and the Appium server, supporting gestures like Drag And Drop and Flick, as well as Appium v2 iOS Alert handling. Requires Python 3.9+ and Appium Python Client 5.1.1+.

Tokens
3K
Snippets
12
Records
17
Agent score
65%

What's inside robotframework-appiumlibrary

  1. Submit a bug report for AppiumLibrary

    master

    When reporting a bug, you must provide a detailed environment description and steps to reproduce the issue to help maintainers. Include the following technical details:

    • Python version (e.g., 3.11.4)
    • Appium version (e.g., 2.5.1)
    • Appium Python Client version (e.g., 5.1.1)
    • AppiumLibrary version (e.g., 3.1)
    • Platform (iOS or Android) and version (e.g., Android 14, iOS 17.2)
    • Driver and its version (e.g., UIAutomator2 2.34.1, XCUITest 5.12.0)
    • Device information (Simulator/real device and model)
    • Steps to reproduce (a minimal test case)
    • Error messages (the full stack trace)
    • Expected vs. actual behavior

    Warning: Do not include any private or confidential information, as all submissions are public.

    **Environment:** 
    
    - Python: 3.11.4 
    - Appium Server: 2.5.1 
    - Appium Python Client: 5.1.1 
    - AppiumLibrary: 3.1 
    - Platform: Android 14 
    - Driver: UIAutomator2 2.34.1 
    - Device: Pixel 7 (emulator) 
    
    **Keyword:** 
    `Open Application` 
    
    **Description:** 
    [Describe the issue here]
    
    **Steps to Reproduce:** 
    1. [Step 1]
    2. [Step 2]
    
    **Expected Result:** 
    [What should happen]
    
    **Actual Result:** 
    [What actually happens]
    
    **Error Message:** 

    [Stack trace here]

    
    **Minimal Example:**
    ```robotframework
    *** Test Cases ***
    Example
        Open Application    http://127.0.0.1:4723
        ...    platformName=Android
  2. Development setup for AppiumLibrary contributors

    master

    If you are contributing to the library, follow these steps to set up your local development environment:

    1. Clone your fork of the repository.
    2. Create and activate a virtual environment.
    3. Install development dependencies using test_require.txt and dev_requirements.txt.
    4. Install the package in editable mode.
    # 1. Clone
    git clone https://github.com/YOUR_USERNAME/robotframework-appiumlibrary.git
    cd robotframework-appiumlibrary
    
    # 2. Virtual Environment
    python -m venv venv
    source venv/bin/activate  # On Windows: venv\Scripts\activate
    
    # 3. Dependencies
    pip install -r test_require.txt
    pip install -r dev_requirements.txt
    pip install -e .
  3. Request a new feature

    master

    To request a feature or enhancement:

    1. Check existing issues to see if it has already been suggested.
    2. If not, create a new GitHub issue with the label enhancement.
    3. Describe the feature, your specific use case, and how it benefits the community.
    4. Include example usage and consider how the feature affects both iOS and Android platforms.
    5. Be prepared to discuss the implementation approach with maintainers before starting work.
  4. Set up mobile devices for Appium testing

    master

    After installing the library, you must set up a simulator/emulator or a real device. The setup process differs for iOS and Android.

    It is recommended to follow the Driver-Specific Setup instructions provided by the Appium project to ensure your development environment (including the Appium server and drivers) is correctly configured.

  5. Use AppiumLibrary in Robot Framework tests

    master

    To use the library, import AppiumLibrary in your Robot Framework test suite's *** Settings *** section.

    Because AppiumLibrary keywords are relatively low-level, it is a best practice to wrap them in higher-level custom keywords to make your tests more readable and maintainable.

    Note: You must provide the Appium server URL (e.g., http://127.0.0.1:4723/wd/hub) and platform-specific capabilities (like automationName, platformName, app, etc.) when calling Open Application.

    *** Settings ***
    Documentation  Simple example using AppiumLibrary
    Library  AppiumLibrary
    
    *** Variables ***
    ${ANDROID_AUTOMATION_NAME}    UIAutomator2
    ${ANDROID_APP}                ${CURDIR}/demoapp/ApiDemos-debug.apk
    ${ANDROID_PLATFORM_NAME}      Android
    ${ANDROID_PLATFORM_VERSION}   %{ANDROID_PLATFORM_VERSION=11}
    
    *** Test Cases ***
    Should send keys to search box and then check the value
      Open Test Application
      Input Search Query  Hello World!
      Submit Search
      Search Query Should Be Matching  Hello World!
    
    *** Keywords ***
    Open Test Application
      Open Application  http://127.0.0.1:4723/wd/hub  automationName=${ANDROID_AUTOMATION_NAME}
      ...  platformName=${ANDROID_PLATFORM_NAME}  platformVersion=${ANDROID_PLATFORM_VERSION}
      ...  app=${ANDROID_APP}  appPackage=io.appium.android.apis  appActivity=.app.SearchInvoke
    
    Input Search Query
      [Arguments]  ${query}
      Input Text  txt_query_prefill  ${query}
    
    Submit Search
      Click Element  btn_start_search
    
    Search Query Should Be Matching
      [Arguments]  ${text}
      Wait Until Page Contains Element  android:id/search_src_text
      Element Text Should Be  android:id/search_src_text  ${text}
  6. Submit code changes via Pull Request

    master

    Follow these steps to contribute code to the repository:

    1. Create a new branch for your feature or bugfix:
      git checkout -b my-feature-branch
    2. Make changes and commit them with clear, descriptive messages.
    3. Push your branch to your fork:
      git push origin my-feature-branch
    4. Open a pull request against the main repository.
    5. Ensure CI checks pass and address any feedback provided during the review process.
    git checkout -b my-feature-branch
    git push origin my-feature-branch
  7. Install AppiumLibrary from GitHub source

    master

    If you need the latest source from the master branch, you can install directly from the GitHub repository using pip. Note that this may take longer as pip clones the repository to a temporary directory before installation.

    pip install git+https://github.com/serhatbolsu/robotframework-appiumlibrary.git
  8. Configure sleep between wait loops in AppiumLibrary

    master

    You can configure the amount of time the library sleeps between iterations of a Wait Until... loop. This can be set globally when importing the library or dynamically during test execution using keywords.

    • Library Import: Use the sleep_between_wait_loop argument when importing the library.
    • Keywords:
      • Use a keyword to set the sleep duration.
      • Use Get Sleep Between Wait to retrieve the current sleep duration.
    # Example: Setting sleep during library import
    Library    AppiumLibrary    sleep_between_wait_loop=0.5