# How to store elements into a list while scrolling?

**URL:** <https://discuss.appium.io/t/how-to-store-elements-into-a-list-while-scrolling/32889>\
**Category:** Support\
**Created:** [January 26, 2021, 4:14pm UTC](https://discuss.appium.io/t/how-to-store-elements-into-a-list-while-scrolling/32889 "2021-01-26T16:14:57Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Karunakar\_Battu](https://discuss.appium.io/user_avatar/discuss.appium.io/karunakar_battu/32/8521_2.png) [@Karunakar\_Battu](https://discuss.appium.io/u/Karunakar_Battu)\
**Post date:** [January 26, 2021, 4:14pm UTC](https://discuss.appium.io/t/how-to-store-elements-into-a-list-while-scrolling/32889/1 "2021-01-26T16:14:57Z")

</div>

How to store elements visible on screen into a list while scrolling

Scenario:  
Scrolling through a list of songs in Playlist, I am able to store only elements visible on screen. Could you please help me on storing elements into a list while scrolling

---

<div class="post-metadata">

**Author:** ![wreed](https://discuss.appium.io/letter_avatar_proxy/v4/letter/w/919ad9/32.png) [@wreed](https://discuss.appium.io/u/wreed)\
**Post date:** [January 27, 2021, 5:52pm UTC](https://discuss.appium.io/t/how-to-store-elements-into-a-list-while-scrolling/32889/2 "2021-01-27T17:52:33Z")

</div>

Here’s some pseudocode to get you going. If you have duplicated songs you may need to check more than one element. It’s a clear use case for recursion:

```
main
  initialize list
  initialize finalList
  screen is presented
  list = getElements
  finalList = getAllElements(list)
end

getAllElements(list)
  initialize myList = list
  initialize iterateList
  scroll
  iterateList = getElements
  if iterateList.last == myList.last
    return myList
  else
    myList += iterateList
    iterateList.clear
    getAllElements(myList)
  end
end
```
