-
-
Save ngtrphuong/1d943c60a7c8e13e46f86406cd2ac288 to your computer and use it in GitHub Desktop.
Demo Scroll Down / Scroll Up using Swipe keyword in Robot Framework
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
*** 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} put_your_device_id_here | |
${ALIAS} Android | |
*** Test Case *** | |
Test Swipe Recycler View | |
Open App | |
Repeat Keyword 3 times Swipe Up | |
Swipe Down | |
*** 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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment