0

Tryin to scroll through a scroll box within a page, the html code looks like this:

<main data-infinite-scroll-context="" id="chat" data-chat-initialized="true" data-chat-current-filter="inbox" class="flex-auto h-100 overflow-auto"></main>

So far I have tried:

for i in range(0, 10):
htmlElem = browser.find_element_by_xpath('//*[@class="flex-auto h-100 overflow-auto""]')
htmlElem.send_keys(Keys.END)
print(i)
time.sleep(2)

and:

for i in range(0, 10):
    htmlElem = browser.find_element_by_tag_name('body')
    htmlElem.send_keys(Keys.END)
    print(i)
    time.sleep(2)

Neither of which are leading to the desired result. Would appreciate some help if possible.

Artur Podlesniy
  • 145
  • 1
  • 7

1 Answers1

0

I had this problem 2 years ago, problem was the selection of the field to send keys. Solution for me was a action chain.

        actions = webdriver.ActionChains(self.driver)
        actions.move_to_element(body_element)
        actions.click()
        for x in range(scroll_count):
            actions.send_keys(Keys.PAGE_DOWN)
            actions.wait(1)

        actions.perform()
fredo.r
  • 381
  • 1
  • 2
  • 14