0

The below code is working for me, elements are get scrolled down, but My problem is, when i am trying the same in another URL it will scroll down up to some particular limits (350).

My sample URL page looks like


| data1 | data1 |
| data2 | data1 |
| data3 | data3 |
| data3 | data4 |
.
.
.
.
.
.
.
.
| data 500 | data 500 |

Below code scroll down only up to 350

def Scrolling():
global status,driver,wait
try:
    # scroll = driver.find_element(By.XPATH,"(//div[contains(@class,'by-pass-flex')])[8]")
    scroll = driver.find_element(By.XPATH, "(//div[contains(@class,'tile-container with-actions')])[49]")
    scroll.location_once_scrolled_into_view
    time.sleep(5)
    scroll = driver.find_element(By.XPATH, "(//div[contains(@class,'tile-container with-actions')])[99]")
    scroll.location_once_scrolled_into_view
    time.sleep(5)
    driver.find_element
    scroll = driver.find_element(By.XPATH, "(//div[contains(@class,'tile-container with-actions')])[149]")
    scroll.location_once_scrolled_into_view
    time.sleep(5)
    scroll = driver.find_element(By.XPATH, "(//div[contains(@class,'tile-container with-actions')])[199]")
    scroll.location_once_scrolled_into_view
    time.sleep(5)
except:
    status="fail"
    print("Scrolling page - Failed")


I am expecting page get scroll down up to bottom of the page

How to handle it?
Bhalaji NM
  • 13
  • 3

1 Answers1

0

The function you are using is for scrolling to a particular element of your website. Without further code of the url it could be assumed that your web element is only 350 lines below the start of the page.

If you want to scroll to the bottom of the page regardless of any web-elements you can use:

driver.execute_script("window.scrollTo(0, document.body.scrollHeight);")

If your page is infinite, the following post will help you:

How can I scroll a web page using selenium webdriver in python?

Fabiii
  • 1
  • 2