I am trying to get the program to scroll in a specific div
to load all the needed elements contained in it. As far as I can tell, the JavaScript code is correct but it keeps giving me this error:
selenium.common.exceptions.JavascriptException: Message: TypeError: document.getElementsByClassName(...)[0] is undefined
This is the line the error refers to:
bot.execute_script("document.getElementsByClassName('uiScrollableAreaBody')[0].scrollTo(0,1000)")
Seems to be the script is trying to get the element before it loads on the page. Try using the explicit wait or
time.sleep(x)
(Personally I prefer the first approach so that you script does not halt for x number of seconds.Here is the pseudo code.