Jun-15-2019, 05:38 PM
This method is supposed to find the comment box on youtube, right now, my scrolling method does not seem to be working. I can't seem to figure out why. Any ideas?
def find_comment_box(self): try: self.browser.get(self.url) SCROLL_PAUSE_TIME = 0.5 # Get scroll height last_height = self.browser.execute_script("return document.body.scrollHeight") while True: # Scroll down to bottom self.browser.execute_script("window.scrollTo(0, document.body.scrollHeight);") # Wait to load page time.sleep(SCROLL_PAUSE_TIME) # Calculate new scroll height and compare with last scroll height new_height = self.browser.execute_script("return document.body.scrollHeight") if new_height == last_height: break if last_height != new_height: pass print("hello") self.comment_box = self.browser.find_element_by_id("contenteditable-root") except Exception as internalerror: print(internalerror) print(self.error)