A library to wait for websites to load, files to download, a method to return, etc...
pip install git+https://github.com/GitPushPullLegs/wait.git
Waiting for any function to return
from wait import Wait
from random import randrange
def function_that_needs_to_return():
if randrange(10) == 2:
return "It's 2!"
result = Wait(timeout=60, poll_frequency=1.5).until(function_that_needs_to_return) # Notice the lack of ().
print(result)
Waiting for a download to complete
from wait import BrowserWait
from selenium import webdriver
# A random selenium chrome driver.
driver_path = 'path_to_chrome_driver'
driver = webdriver.Chrome(executable_path=driver_path)
file_path = BrowserWait(driver=driver).until_file_downloaded()
print(file_path) # The file path to the downloaded file.