Skip to content

Instantly share code, notes, and snippets.

@AlexanderPi
Forked from semutmerah/TestSwipe.robot
Created May 22, 2020 06:01
Show Gist options
  • Select an option

  • Save AlexanderPi/7e88cb7ce885634a97c6e0d0e172095b to your computer and use it in GitHub Desktop.

Select an option

Save AlexanderPi/7e88cb7ce885634a97c6e0d0e172095b to your computer and use it in GitHub Desktop.

Revisions

  1. @semutmerah semutmerah revised this gist Jul 5, 2018. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion TestSwipe.robot
    Original file line number Diff line number Diff line change
    @@ -16,7 +16,7 @@ ${APPIUM_PORT} 49152
    ${APPIUM_SERVER} http://127.0.0.1:${APPIUM_PORT}/wd/hub
    ${BOOTSTRAP_PORT} 50000
    ${PLATFORM} Android
    ${UDID} 32d6ecb10504
    ${UDID} put_your_device_id_here
    ${ALIAS} Android

    *** Test Case ***
  2. @semutmerah semutmerah revised this gist May 23, 2018. 1 changed file with 0 additions and 2 deletions.
    2 changes: 0 additions & 2 deletions TestSwipe.robot
    Original file line number Diff line number Diff line change
    @@ -23,9 +23,7 @@ ${ALIAS} Android
    Test Swipe Recycler View
    Open App
    Repeat Keyword 3 times Swipe Up
    Sleep 5
    Swipe Down
    Sleep 5

    *** Keywords ***
    Open App
  3. @semutmerah semutmerah created this gist May 22, 2018.
    68 changes: 68 additions & 0 deletions TestSwipe.robot
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,68 @@
    *** Settings ***
    Library AppiumLibrary 15 run_on_failure=Log Source
    Library Process

    Suite Setup Spawn Appium Server
    Suite Teardown Close Appium Server
    Test Teardown Close Application

    *** Variables ***
    ## Go here to download the apk for the app used in this test -> https://drive.google.com/file/d/19FxLjux8ZtumweXzBA_CYrL0Va-BL4gY/view?usp=sharing
    ## The app test is using recycler view app example from google
    ${APP_PACKAGE} com.example.android.recyclerview
    ${APP_ACTIVITY} com.example.android.recyclerview.MainActivity

    ${APPIUM_PORT} 49152
    ${APPIUM_SERVER} http://127.0.0.1:${APPIUM_PORT}/wd/hub
    ${BOOTSTRAP_PORT} 50000
    ${PLATFORM} Android
    ${UDID} 32d6ecb10504
    ${ALIAS} Android

    *** Test Case ***
    Test Swipe Recycler View
    Open App
    Repeat Keyword 3 times Swipe Up
    Sleep 5
    Swipe Down
    Sleep 5

    *** Keywords ***
    Open App
    Open Application ${APPIUM_SERVER} platformName=${PLATFORM} udid=${UDID} deviceName=${ALIAS} app=${APP_PACKAGE} appActivity=${APP_ACTIVITY} alias=${ALIAS} noReset=True
    Wait Until Page Contains Element id=sample_content_fragment

    Swipe Up
    ${element_size}= Get Element Size id=sample_content_fragment
    ${element_location}= Get Element Location id=sample_content_fragment
    ${start_x}= Evaluate ${element_location['x']} + (${element_size['width']} * 0.5)
    ${start_y}= Evaluate ${element_location['y']} + (${element_size['height']} * 0.7)
    ${end_x}= Evaluate ${element_location['x']} + (${element_size['width']} * 0.5)
    ${end_y}= Evaluate ${element_location['y']} + (${element_size['height']} * 0.3)
    Swipe ${start_x} ${start_y} ${end_x} ${end_y} 500
    Sleep 1

    Swipe Down
    ${element_size}= Get Element Size id=sample_content_fragment
    ${element_location}= Get Element Location id=sample_content_fragment
    ${start_x}= Evaluate ${element_location['x']} + (${element_size['width']} * 0.5)
    ${start_y}= Evaluate ${element_location['y']} + (${element_size['height']} * 0.3)
    ${end_x}= Evaluate ${element_location['x']} + (${element_size['width']} * 0.5)
    ${end_y}= Evaluate ${element_location['y']} + (${element_size['height']} * 0.7)
    Swipe ${start_x} ${start_y} ${end_x} ${end_y} 500
    Sleep 1

    Get Working Path
    Run Process pwd shell=True alias=proc1
    ${WORKING_PATH}= Get Process Result proc1 stdout=true
    Set Suite Variable ${WORKING_PATH}

    Spawn Appium Server
    Get Working Path
    Start Process appium -p ${APPIUM_PORT} -bp ${BOOTSTRAP_PORT} stdout=${WORKING_PATH}/appium-log-${ALIAS}.txt shell=true
    Sleep 5

    Close Appium Server
    Run Keyword And Ignore Error Close All Applications
    Terminate All Processes kill=True
    Sleep 5