Skip to content

Instantly share code, notes, and snippets.

View wallacefcosta's full-sized avatar
😀

Wallace wallacefcosta

😀
View GitHub Profile
@munro
munro / selenium_wait_for_images_loaded.py
Last active June 15, 2024 01:12
Selenium wait for all images to load, including background images.
from textwrap import dedent
def wait_until_images_loaded(driver, timeout=30):
"""Waits for all images & background images to load."""
driver.set_script_timeout(timeout)
driver.execute_async_script(dedent('''
// Function to extract URL from CSS 'url()' function
function extractCSSURL(text) {
var url_str = text.replace(/.*url\((.*)\).*/, '$1');