I am trying to load the page with Selenium and parse it with Beautiful Soup. I have tried different ways to simulate the click on the load more button, only the code here works. [How to scroll down in Python Selenium step by step
read_mores = driver.find_elements_by_xpath('//*[@data-teach-id='+ tid + ']')
for read_more in read_mores:
driver.execute_script("arguments[0].scrollIntoView();", read_more)
driver.execute_script("$(arguments[0]).click();", read_more)
soup = BeautifulSoup(driver.page_source, 'html.parser')
However, it fails to load the whole page sometimes. I know probably "clickandwait" will work but have no idea where to put in the code. I would also love to know if there is other way to deal with it. Any help would be greatly appreciated!