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.

3

1 Answer 1

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()
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.