0

On the page that I am parsing, a dialog box appears that is labelled '.isgrP' and I need it to scroll down and through the list that appears in order to continue. I searched through stackoverflow for solutions and the closest one that I came up with was this:

WebDriverWait(driver, 10).until(lambda d: d.find_element_by_css_selector('div[role="dialog"]'))

driver.execute_script('''
    var fDialog = document.querySelector('div[role="dialog"] .isgrP');
    fDialog.scrollTop = fDialog.scrollHeight
''')

I believe this solution that I came across uses Java as opposed to just selenium or python. The issue with this code is that it scrolls too quickly and is detected to be a bot so the page no longer loads. I am wondering if there is anyway to lower the scroll speed or make it mimic a human's scroll speed?

Artur Podlesniy
  • 145
  • 1
  • 7
  • 1
    The closest thing to slowly scrolling would be scrolling in smaller increments, and waiting between each scroll. But, each individual "scroll" action will still appear to be bot-like. There are small workarounds to websites that do not allow bots, but overall, Selenium is not meant to be used on these websites at all. – CEH Nov 26 '19 at 01:23
  • What would the commands be to make scrolling in slower increments? I want to test if I can use a randomint variable in place of a set speed. – Artur Podlesniy Nov 26 '19 at 01:51
  • Try emulating wheel scroll like mentioned in this answer https://stackoverflow.com/questions/47274852/mouse-scroll-wheel-with-selenium-webdriver-on-element-without-scrollbar – Amith YR Nov 26 '19 at 04:49
  • Here I described how to smooth scroll in case you don't know how long the page will be scrolled. https://stackoverflow.com/questions/56689143/selenium-webdriver-does-not-find-the-correct-number-of-elements/56692073#56692073 – Gennady Zyablitsev Nov 26 '19 at 10:47

0 Answers0