# Scroll element to view / execute javascript

**URL:** <https://forum.robotframework.org/t/scroll-element-to-view-execute-javascript/957>\
**Category:** SeleniumLibrary\
**Created:** [12 November 2020 05:17 UTC](https://forum.robotframework.org/t/scroll-element-to-view-execute-javascript/957 "2020-11-12T05:17:42Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sonal](https://avatars.discourse-cdn.com/v4/letter/s/a9a28c/32.png) [@Sonal](https://forum.robotframework.org/u/Sonal)\
**Post date:** [12 November 2020 05:17 UTC](https://forum.robotframework.org/t/scroll-element-to-view-execute-javascript/957/1 "2020-11-12T05:17:42Z")

</div>

Hi all my use case is : to find if certain element is visible if we scroll down the page , I used execute Java script to scroll to the bottom of the page , but instead going to the bottom the scroller stops at the middle of the page and says element not found , I used scroll element to view but it says the element cannot be scrolled to view , the only spl feature in my we application is that it uses lazy loading and loads certain elements only when the user scrolls down and the page loading is asynchronous .

---

<div class="post-metadata">

**Author:** ![René](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/ren%C3%A9/32/7_2.png) [@René](https://forum.robotframework.org/u/Ren%C3%A9)\
**Post date:** [12 November 2020 09:11 UTC](https://forum.robotframework.org/t/scroll-element-to-view-execute-javascript/957/2 "2020-11-12T09:11:53Z")

</div>

Can you please tell us what JS command you where using to scroll down?  
And if you are doing lazy loading on that page, bottom is only bottom when you are at the top.  
once you are at the bottom, it loads new stuff and now your position is not bottom anymore.

You may want to do a for loop that Scolls a page down, checks if an element is visible and if not scrolls again one page down.  
You do that as often as needed until you element gets visible or until the scollHeight is not changing anymore.

---

<div class="post-metadata">

**Author:** ![Sonal](https://avatars.discourse-cdn.com/v4/letter/s/a9a28c/32.png) [@Sonal](https://forum.robotframework.org/u/Sonal)\
**Post date:** [24 November 2020 07:48 UTC](https://forum.robotframework.org/t/scroll-element-to-view-execute-javascript/957/3 "2020-11-24T07:48:05Z")

</div>

Hi Rene , Sorry for late reply I tried using :  
Execute JavaScript window.scrollTo(0,3000)

Execute JavaScript window.scrollBy(0,4000)

Execute JavaScript window.scrollTo(0, document.body.scrollHeight)  
but the page doesnot scrolls to the bottom , i want to verify things on footer  
later i found we had some lazy loading things on web application that might interfere here.

---

<div class="post-metadata">

**Author:** ![weh2017](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/weh2017/32/565_2.png) [@weh2017](https://forum.robotframework.org/u/weh2017)\
**Post date:** [14 December 2020 10:59 UTC](https://forum.robotframework.org/t/scroll-element-to-view-execute-javascript/957/4 "2020-12-14T10:59:03Z")

</div>

I’ve been experiencing this before wherein I can’t scroll down using Execute javascript KW. In order to be successful, I’m using a Scroll Element Into View KW and it works!
