Scroll/Scroll To in AppiumLibrary (android testing)

6,356 views
Skip to first unread message

Karolina

unread,
Jan 26, 2016, 4:50:58 AM1/26/16
to robotframework-users
Hi, 

I have problem with screen scrolling in my native android app using AppiumLibrary in Robot Framework (ride 1.5.2).
I use two solutions listed below, every time I got the message:
ValueError: Element locator 'id=v_languages' did not match any elements.

1. Using Scroll:

Scroll id=et_first_name id=v_languages

2. Using Scroll To:

Scroll To id=v_languages


ID is for sure correct. 

Any advice what could be wrong?

thx,
K.

Jari Nurminen

unread,
Jan 26, 2016, 6:59:52 AM1/26/16
to walendzik...@gmail.com, robotframework-users
Hi Karolina,
 
I never got it working either, it fails because the ID to scroll to is not visible on the screen. It works if the ID is on the screen = it scrolls the screen a bit. That is, of course, rather useless like this...
Not 100% sure whether this is a bug, or something that is not yet implemented on appium side. The hits you find with google are rather confusing, at least to me without too much "Appium Internals" knowledge.
But I would be interested about your findings (which version of appium you have tried, in which contexts are you scrolling (Android/iOS + Native/Web)...
 
The workaround I had to implement was: 1) call "swipe" KW + 2) check if the ID is visible, if not goto 1)
 
cheerio,
- Jari -
--
You received this message because you are subscribed to the Google Groups "robotframework-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to robotframework-u...@googlegroups.com.
To post to this group, send email to robotframe...@googlegroups.com.
Visit this group at https://groups.google.com/group/robotframework-users.
For more options, visit https://groups.google.com/d/optout.

Karolina

unread,
Jan 26, 2016, 9:11:59 AM1/26/16
to robotframework-users, walendzik...@gmail.com, jari...@gmail.com
Hi Jeri,

thanks,It was helpful!

I use Swipe and For Loop, like this:

    : FOR    ${licznik}    IN RANGE    0    5
    \    Swipe    15    600    15    200
    \    ${el}    Run Keyword And Return Status    Wait Until Page Contains Element    ${lokalizator}
    \    log    ${el}
    \    Run Keyword If    ${el}     Exit For Loop
    \    ${licznik}    Set Variable    ${licznik}+1

Next step will be to check the size of the screen in order to the tests were unique, but for now it is enough.:)

Regards,
Karolina
To unsubscribe from this group and stop receiving emails from it, send an email to robotframework-users+unsub...@googlegroups.com.

Tatu Aalto

unread,
Jan 27, 2016, 10:45:06 AM1/27/16
to Jari Nurminen, robotframe...@googlegroups.com
Ugh

Yes I am, in python, this is done:
driver.find_element_by_android_uiautomator(new UiScrollable(new
UiSelector().scrollable(true)).scrollIntoView(new
UiSelector().text("element text goes here")))

-Tatu

On 1/26/16, Jari Nurminen <jari...@gmail.com> wrote:
> Howdy,
>
> are you using this through Appium's Python Client?
> If yes, would you mind sharing the code snippet how to use this...
>
> - J -
>
> ------ Original Message ------
> From: "Tatu Aalto" <aalto...@gmail.com>
> To: "Jari Nurminen" <jari...@gmail.com>
> Sent: 26.01.2016 13:26:09
> Subject: Re: Scroll/Scroll To in AppiumLibrary (android testing)
>
>>Ugh
>>
>>It is also possible to use android SDK uiautomator and perform scroll.
>>With uiautomator it is possible to scroll to element which is currently
>>invisible. More details in android SDK document [1].
>>
>>-Tatu
>>Send from my mobile
>>[1]
>>http://developer.android.com/reference/android/support/test/uiautomator/UiScrollable.html
>>>>send an email to robotframework-u...@googlegroups.com.
>>>>To post to this group, send email to
>>>>robotframe...@googlegroups.com.
>>>>Visit this group at
>>>>https://groups.google.com/group/robotframework-users.
>>>>For more options, visit https://groups.google.com/d/optout.
>>>
>>>--
>>>You received this message because you are subscribed to the Google
>>>Groups "robotframework-users" group.
>>>To unsubscribe from this group and stop receiving emails from it, send
>>>an email to robotframework-u...@googlegroups.com.

Jari Nurminen

unread,
Feb 1, 2016, 1:21:37 AM2/1/16
to Tatu Aalto, robotframe...@googlegroups.com
cool, thanks. Works like a charm...

bharat joshi

unread,
Mar 25, 2016, 3:37:08 AM3/25/16
to robotframework-users
@ Tatu

Please help me on how did u used python code as mentioned

I mean do i need to create some library file and put that code into any function

Please help me understand it

bharat joshi

unread,
Mar 25, 2016, 3:44:00 AM3/25/16
to robotframework-users, jari...@gmail.com
Hi Tatu ,

Please help me understand , how did used the below code

Did you created any library file and created a function inside it and then used that function

Please help me
>>>>To post to this group, send email to
>>>>Visit this group at
>>>>https://groups.google.com/group/robotframework-users.
>>>>For more options, visit https://groups.google.com/d/optout.
>>>
>>>--
>>>You received this message because you are subscribed to the Google
>>>Groups "robotframework-users" group.
>>>To unsubscribe from this group and stop receiving emails from it, send
>>>To post to this group, send email to

Tatu Aalto

unread,
Mar 26, 2016, 12:14:35 PM3/26/16
to bharat...@gmail.com, Jari Nurminen, robotframework-users

Ugh

It depends what you want to do. That selector, text inside of the outermost parentheses, is valid Android uiautomator selector and you should be able to use it with any keyword which accepts uiautomator selectors. All the scrolling logic happens inside of the Android uiautomator and it should not matter what action you/keyword performs when the element is visible.

-Tatu

>>>>To post to this group, send email to
>>>>Visit this group at
>>>>https://groups.google.com/group/robotframework-users.
>>>>For more options, visit https://groups.google.com/d/optout.
>>>
>>>--
>>>You received this message because you are subscribed to the Google
>>>Groups "robotframework-users" group.
>>>To unsubscribe from this group and stop receiving emails from it, send
>>>To post to this group, send email to

--
You received this message because you are subscribed to the Google Groups "robotframework-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to robotframework-u...@googlegroups.com.
To post to this group, send email to robotframe...@googlegroups.com.

ivan.sa...@gmail.com

unread,
May 8, 2018, 9:05:00 AM5/8/18
to robotframework-users
Than you, Karolina. It was helpful for me.

For Testing

unread,
May 10, 2018, 3:26:18 PM5/10/18
to robotframework-users
HI all,
   
     I am using appium version 1.7, Robot framework and AppiumLibrary.
I tried so many options to scoll in Android but nothing helped.

Tablet  tries-
# No error didn't work
AppiumLibrary.Scroll Down    id=quick-view-container
# Method not implemented error
AppiumLibrary.Scroll    id=inqC2CImgContainer    id=quick-view-container
# Swipe - error method not implemented
AppiumLibrary.Swipe    100    100    1000    100

iPad tries-
Scroll worked for native app such as Settings on iPad but didn't work for Android native app.
    Trials for website. 
        # - error - can't scroll to element that does not exists. (I know element exists for sure)
AppiumLibrary.Scroll    id=inqC2CImgContainer    id=quick-view-container
# No Error but didn't actually scroll down
AppiumLibrary.Scroll Down    id=quick-view-container
# Swipe - No error but it doesn't actually swipes. It swiped but does something weird. 
AppiumLibrary.Swipe    300    300    300    1000


All of you who have found solution for this please please help me.. Many of my tests are stuck for this scroll and swipe issue.

Thanks
Priti

Doanh Nguyễn văn

unread,
Jun 7, 2018, 12:23:08 AM6/7/18
to robotframework-users
If you have any simple for test suite for mobile testing. Please share it!. I;m getting familiar with this :)

Thanks,
DoanhPoPu

Vào 16:50:58 UTC+7 Thứ Ba, ngày 26 tháng 1 năm 2016, Karolina đã viết:

dou...@zapalago.com

unread,
Oct 8, 2018, 2:12:21 PM10/8/18
to robotframework-users
This work for me, but, only on Native context. Thanks!

Sri Hari Naidu

unread,
Mar 13, 2019, 6:33:52 AM3/13/19
to robotframework-users
Hi Tanu,

Could you please suggest me how to achieve this using python? If possible could you please share code snippet. 
>>>>To post to this group, send email to
>>>>robotframe...@googlegroups.com.
>>>>Visit this group at
>>>>https://groups.google.com/group/robotframework-users.
>>>>For more options, visit https://groups.google.com/d/optout.
>>>
>>>--
>>>You received this message because you are subscribed to the Google
>>>Groups "robotframework-users" group.
>>>To unsubscribe from this group and stop receiving emails from it, send
>>>To post to this group, send email to
>>>robotframe...@googlegroups.com.
>>>Visit this group at
>>>https://groups.google.com/group/robotframework-users.
>>>For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "robotframework-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to robotframework-users+unsub...@googlegroups.com.

Flora Giannone

unread,
Mar 13, 2019, 6:40:38 AM3/13/19
to srihar...@misport.com, robotframework-users
Hello

this one is working for me :

def scroll_to(text):
get_driver_instance().find_element_by_android_uiautomator(
"new UiScrollable(new UiSelector().scrollable(true).instance(0)).scrollIntoView("
"new UiSelector().textContains(\""+text+"\").instance(0))")

Hi Tanu,

>>>>To post to this group, send email to
>>>>robotframe...@googlegroups.com.
>>>>Visit this group at
>>>>https://groups.google.com/group/robotframework-users.
>>>>For more options, visit https://groups.google.com/d/optout.
>>>
>>>--
>>>You received this message because you are subscribed to the Google
>>>Groups "robotframework-users" group.
>>>To unsubscribe from this group and stop receiving emails from it, send
>>>To post to this group, send email to
>>>robotframe...@googlegroups.com.
>>>Visit this group at
>>>https://groups.google.com/group/robotframework-users.
>>>For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "robotframework-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to robotframework-u...@googlegroups.com.

To post to this group, send email to robotframe...@googlegroups.com.
Visit this group at https://groups.google.com/group/robotframework-users.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "robotframework-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to robotframework-u...@googlegroups.com.

To post to this group, send email to robotframe...@googlegroups.com.
Visit this group at https://groups.google.com/group/robotframework-users.
For more options, visit https://groups.google.com/d/optout.


--
FG

Sri Hari Naidu

unread,
Mar 13, 2019, 6:52:21 AM3/13/19
to Flora Giannone, robotframework-users
Hello,

I'm new to the RobotFramework, Could you please explain a bit more. I just used the code but it's saying error. 

Screen Shot 2019-03-13 at 4.20.32 PM.png
Thanks & Regards
P.Srihari

Flora Giannone

unread,
Mar 13, 2019, 7:28:45 AM3/13/19
to Sri Hari Naidu, robotframework-users
Sorry my mistake u also need:

from robot.libraries.BuiltIn import BuiltIn
def get_driver_instance():
driver = BuiltIn().get_library_instance('AppiumLibrary')
return driver._current_application()
--
FG

Sri Hari Naidu

unread,
Mar 13, 2019, 8:38:14 AM3/13/19
to robotframework-users
Hi Flora,

Thanks for helping me out. But still not able to achieve the scrolling. 

Writing the python code and try to write the keyword using this code but still getting same error. 

import os
from appium import webdriver
from robot.libraries.BuiltIn import BuiltIn
from appium.webdriver.common.touch_action import TouchAction


class Andy():
desired_caps = {
'appPackage': 'com.pision.debug',
'appActivity': 'com.pision.android.activities.Splash',
'platformName': 'Android',
'platformVersion': 6,
'deviceName': 'SORS9LY54HEA4SFE',
'app': ('/Users/reenupanwar/Desktop/AppBuild/P20190211.apk')
}


APPIUM_LOCAL_HOST_URL = 'http://localhost:4723/wd/hub'
driver = webdriver.Remote(APPIUM_LOCAL_HOST_URL, desired_caps)
actions = TouchAction(driver)


def get_driver_instance(self):

driver = BuiltIn().get_library_instance('AppiumLibrary')
return driver._current_application()


def scroll_to(xpath):
xpath="xpath=//android.widget.TextView[@text='Check this out']"
get_driver_instance().find_element_by_android_uiautomator(
"new UiScrollable(new UiSelector().scrollable(true).instance(0)).scrollIntoView("
"new UiSelector().textContains(\"" + xpath + "\").instance(0))")
Hi Tanu,

>>>>To post to this group, send email to
>>>>robotframe...@googlegroups.com.
>>>>Visit this group at
>>>>https://groups.google.com/group/robotframework-users.
>>>>For more options, visit https://groups.google.com/d/optout.
>>>
>>>--
>>>You received this message because you are subscribed to the Google
>>>Groups "robotframework-users" group.
>>>To unsubscribe from this group and stop receiving emails from it, send
>>>To post to this group, send email to
>>>robotframe...@googlegroups.com.
>>>Visit this group at
>>>https://groups.google.com/group/robotframework-users.
>>>For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "robotframework-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to robotframework-users+unsub...@googlegroups.com.

To post to this group, send email to robotframe...@googlegroups.com.
Visit this group at https://groups.google.com/group/robotframework-users.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "robotframework-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to robotframework-users+unsub...@googlegroups.com.

To post to this group, send email to robotframe...@googlegroups.com.
Visit this group at https://groups.google.com/group/robotframework-users.
For more options, visit https://groups.google.com/d/optout.


--
FG


--
FG

Tatu Aalto

unread,
Mar 13, 2019, 11:33:17 AM3/13/19
to srihar...@misport.com, robotframework-users
Ugh

You can't join two different selector types. The selector must be same and single type, in this case uiautomator


-Tatu
Send from my mobile
Hi Tanu,

>>>>To post to this group, send email to
>>>>robotframe...@googlegroups.com.
>>>>Visit this group at
>>>>https://groups.google.com/group/robotframework-users.
>>>>For more options, visit https://groups.google.com/d/optout.
>>>
>>>--
>>>You received this message because you are subscribed to the Google
>>>Groups "robotframework-users" group.
>>>To unsubscribe from this group and stop receiving emails from it, send
>>>To post to this group, send email to
>>>robotframe...@googlegroups.com.
>>>Visit this group at
>>>https://groups.google.com/group/robotframework-users.
>>>For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "robotframework-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to robotframework-u...@googlegroups.com.

To post to this group, send email to robotframe...@googlegroups.com.
Visit this group at https://groups.google.com/group/robotframework-users.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "robotframework-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to robotframework-u...@googlegroups.com.

To post to this group, send email to robotframe...@googlegroups.com.
Visit this group at https://groups.google.com/group/robotframework-users.
For more options, visit https://groups.google.com/d/optout.


--
FG


--
FG

--
You received this message because you are subscribed to the Google Groups "robotframework-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to robotframework-u...@googlegroups.com.

Sri Hari Naidu

unread,
Mar 13, 2019, 12:01:47 PM3/13/19
to Tatu Aalto, robotframework-users
Hi Tanu,

If possible could you please send code snippet please Or If possible can you update my code..!

I have achieved the screen scrolling using the Swipe up the keyword, but it not good approach.

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
Thanks & Regards
P.Srihari

Reply all
Reply to author
Forward
0 new messages