OK i figured it out.
The elements change based on whether its clicked or not. So you have to click it to get contenteditable-root ID available. Which before its clicked is ID "placeholder-area".
The elements change based on whether its clicked or not. So you have to click it to get contenteditable-root ID available. Which before its clicked is ID "placeholder-area".
def find_comment_box(self): try: print("Passing URL to Browser...") self.browser.get(self.url) bg = self.browser.find_element_by_css_selector('body') for _ in range(3): bg.send_keys(Keys.PAGE_DOWN) time.sleep(.5) for _ in range(3): bg.send_keys(Keys.PAGE_DOWN) time.sleep(.5) print("Fetching comment box...") self.comment_box = self.browser.find_element_by_id('placeholder-area') self.comment_box.click() time.sleep(2) #self.comment_box = self.browser.find_element_by_xpath("//yt-formatted-string[contains(text(),'Add a public comment...')]") self.comment_box = self.browser.find_element_by_id('contenteditable-root') self.comment_box.send_keys('test')Also you can make your script quicker by using WebDriverWait instead of time.sleep(). This will wait until its ready instead of an arbitrary number you put into time.sleep which actually makes it much faster. Scrolling is the only time i use time.sleep.
Recommended Tutorials: