Running loop synchronously in python Running loop synchronously in python selenium selenium

Running loop synchronously in python


You can set the page_load_timeout to make the driver wait for the page to load

driver.set_page_load_timeout(10)

Another option is to wait for the number of elements to change

current_number_of_news = 0news = []while int(number_of_news) != int(len(news)) :    driver.execute_script("window.scrollTo(document.body.scrollHeight/2, document.body.scrollHeight);")    while (current_number_of_news == len(news)) :        news = driver.find_elements_by_class_name("news-text")    current_number_of_news = len(news)    print(len(news))