Unable to make a split screen scroll to the bottom

Try to use the following method for that:

def scroll_down():
    """A method for scrolling down the page."""

    # Get scroll height.
    last_height = driver.execute_script("return document.querySelector('#pannello-espositori').scrollHeight;")

    while True:

        # Scroll down to the bottom.
        driver.execute_script("window.iScrollElenco.scrollBy(0, -arguments[0]);", last_height)

        # Wait to load the page.
        time.sleep(2)

        # Calculate new scroll height and compare with last scroll height.
        new_height = driver.execute_script("return document.querySelector('#pannello-espositori').scrollHeight;")

        if new_height == last_height:

            break

        last_height = new_height

Use this method when you want to scroll down content (using the height of the left side panel) in the left side panel.

Hope it helps you! Let me know about the result.


Try this. You can see scrolling effect by scrolling up to the elements in the left panel.

This solution would scroll up to first 100 elements.

from selenium import webdriver
import time

def scroll_element_into_view(element):
    driver.execute_script(
        "arguments[0].scrollIntoView(true);",
        element)
    time.sleep(0.2) #increase/decrease time as you want delay in your view

driver = webdriver.Chrome()
driver.maximize_window()
driver.set_page_load_timeout(5)
try:
    driver.get("http://catalogo.marmomac.it/it/cat")
    time.sleep(3)
    total_elems= driver.find_elements_by_css_selector(".scroller .elemento")
    print len(total_elems)
    for i in range(len(total_elems)):
        scroll_element_into_view(total_elems[i])
except Exception as e:
    print e
finally:
    driver.quit()

As you have mentioned, after scroll it would load more elements.Below script would handle that too. Here we can use total count which already shown at top of the panel.

for ex count is : 1669

  1. First it will scroll from 1 to 100 element
  2. Again find total elements which is now 150
  3. So it will scroll from 101 to 150
  4. Again find total elements which is now 200
  5. So it will scroll from 150 to 200

this process would continue till 1669 element. (Store previous count in one variable and update it after every loop)

try:
    driver.get("http://catalogo.marmomac.it/it/cat")
    time.sleep(3)
    total_elems=0
    total_count = int(driver.find_element_by_css_selector(".totali").text)
    while total_elems<total_count:
        elems= driver.find_elements_by_css_selector(".scroller .elemento")
        found_elms= len(elems)
        for i in range(total_elems,found_elms):
            scroll_element_into_view(elems[i])
        total_elems=found_elms
except Exception as e:
    print e
finally:
    driver.quit()