1

I'm using angular in my frontend, in some part of my page I included virtual scrolling:

https://material.angular.io/cdk/scrolling/overview

For those who don't know, it's used to avoid render all the data at once in huge lists, what it does is it include in the frontend only those items that are shown depending on scroll bar.

Now I want to check that all the items are in this virtual table, so, what i need is scroll down until the item locator apears.

I was thinking in something like scroll down about 50 px and check if item is there, if it is, then stop, else continue scrolling.

The problem is I can't find how to scroll using robot framework, I only see:

Scroll Element Into View    ${locator}

But it's not useful for me because my item is not "hidden" it doesnt exist.

is it a way to do something like:

Scroll down my item 50px     ${locator}

And

Scroll my item to top   ${locator}
cucuru
  • 3,456
  • 8
  • 40
  • 74

2 Answers2

0

And what about if element does not have an id? I made this kEYWORD but is a little intrusive with DOM

Scroll to xpath
[Arguments]         ${xpath}
    ${tmp}=     SeleniumLibrary.get element attribute   ${xpath}    id
    assign id to element    ${xpath}     scrollID
    execute javascript      document.getElementById('scrollID').scrollIntoView();
    run keyword if  '${tmp}' != '${EMPTY}'    assign id to element    ${xpath}     ${tmp}

Any suggestions will be appreciated

xrc
  • 52
  • 4
  • it's the same than selenium scrollIntoView, the problem is the element is REMOVED from DOM because this is how virtual scroll works. I need to scroll some px instead of look for the element – cucuru Mar 06 '20 at 07:12
  • @cucuru How did you scroll to a particular locator then ? – vgdub Dec 07 '20 at 00:00
  • 1
    i finally include and use a search button in the view so it was not needed to scroll. – cucuru Dec 07 '20 at 08:30
0

you can use the below keyword

Source: AppiumLibrary [Documentation]

Arguments: [start_locator, end_locator]

Scrolls from one element to another, Key attributes for arbitrary elements are id and name.

Syntax:

Scroll    start_locator    end_locator

in order to use the scroll keyword you would need to have the Appium library Note: both the elements should be visible for the scroll action, the swipe action will be performed with the start element to the end element.

Documentation: https://serhatbolsu.github.io/robotframework-appiumlibrary/AppiumLibrary.html#Scroll