Last active
January 20, 2025 09:05
-
-
Save semutmerah/0ee48987f0b34103b494f73653c1d9e7 to your computer and use it in GitHub Desktop.
Demo Scroll Down / Scroll Up using Swipe keyword in Robot Framework
This file contains hidden or 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 |
Oh ok thank you.
…On Wed, May 20, 2020 at 10:10 AM sidarakeo ***@***.***> wrote:
***@***.**** commented on this gist.
------------------------------
Hi, where did you get this value?
${BOOTSTRAP_PORT} 50000
this is getting from the Appium server config. it's can be any value base
on your config
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<https://gist.github.com/0ee48987f0b34103b494f73653c1d9e7#gistcomment-3310880>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AIG6GT2K724F4OBJE7LNISTRSNC3HANCNFSM4KKUNBGA>
.
get element size throwing this error: AttributeError: 'NoneType' object has no attribute 'size'
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
this is getting from the Appium server config. it's can be any value base on your config