My script is scraping data from a Slack chat for which i don't have an API so i use Selenium for Webscraping, and when i refresh the page i need to scroll at the bottom of the messages page.
I managed to locate effectively the scroll bar with the selector and I'm trying different ways to move the page down, but it doesn't move by an inch.
Thanks for any suggestion!
scroll_selector = 'body > div.p-client_container > div > div > div.p-client_workspace_wrapper > div.p-client_workspace > div.p-client_workspace__layout > div:nth-child(2) > div:nth-child(2) > div > div.p-file_drag_drop__container > div.p-workspace__primary_view_body > div > div:nth-child(3) > div > div > div.c-scrollbar__track > div'
try:
WebDriverWait(driver, 3).until(EC.presence_of_element_located((By.CSS_SELECTOR, scroll_selector)))
scrollbar_track = driver.find_element(By.CSS_SELECTOR, scroll_selector)
print("HTML Element located")
except TimeoutException:
print("HTML Element not located")
# Here different options tried to move the sidebar
driver.execute_script("arguments[0].click();", scrollbar_track)
logger.debug("Scroll bar Clicked")
driver.execute_script("arguments[0].scrollTop = arguments[0].scrollHeight", scrollbar_track)
driver.execute_script("window.scrollTo(0, document.body.scrollHeight);")
scrollbar_track.send_keys(Keys.PAGE_DOWN)
scrollbar_track.send_keys(Keys.DOWN)
time.sleep(2)
scrollbar_track.send_keys(Keys.DOWN)
driver.execute_script("window.scrollTo(0, document.body.scrollHeight);")-- this line should do it... can you open the page and runwindow.scrollTo(0, document.body.scrollHeight)in your browser console to verify it works?