feat: make screenshot timeout configurable (#10517)

* made screenshot timeout configurable

* added default value to config and refractored use

* black

* updated config comment

* moves config variables to thumbnail section

Co-authored-by: Jason Davis <@dropbox.com>
This commit is contained in:
Jason Davis 2020-08-04 17:16:31 -07:00 committed by GitHub
parent e040bf7acf
commit 72ced53d2a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 4 deletions

View File

@ -337,6 +337,12 @@ THUMBNAIL_CACHE_CONFIG: CacheConfig = {
"CACHE_NO_NULL_WARNING": True,
}
# Used for thumbnails and other api: Time in seconds before selenium
# times out after trying to locate an element on the page and wait
# for that element to load for an alert screenshot.
SCREENSHOT_LOCATE_WAIT = 10
SCREENSHOT_LOAD_WAIT = 60
# ---------------------------------------------------
# Image and file configuration
# ---------------------------------------------------

View File

@ -159,11 +159,11 @@ class AuthWebDriverProxy:
time.sleep(SELENIUM_HEADSTART)
try:
logger.debug("Wait for the presence of %s", element_name)
element = WebDriverWait(driver, 10).until(
EC.presence_of_element_located((By.CLASS_NAME, element_name))
)
element = WebDriverWait(
driver, current_app.config["SCREENSHOT_LOCATE_WAIT"]
).until(EC.presence_of_element_located((By.CLASS_NAME, element_name)))
logger.debug("Wait for .loading to be done")
WebDriverWait(driver, 60).until_not(
WebDriverWait(driver, current_app.config["SCREENSHOT_LOAD_WAIT"]).until_not(
EC.presence_of_all_elements_located((By.CLASS_NAME, "loading"))
)
logger.info("Taking a PNG screenshot")