I have a few HTML pages like this:
<!DOCTYPE html><html><head><meta charset="utf-8"><style>@import url(https://fonts.googleapis.com/css?family=Droid+Serif:400,700,400italic); body { font-family: 'Droid Serif'; }</style></head>...
When loading the page with Selenium:
from selenium import webdriverchrome_options = webdriver.ChromeOptions()chrome_options.add_argument('--kiosk-printing')browser = webdriver.Chrome(r"chromedriver.exe", options=chrome_options)browser.get("http://www.example.com/")
then:
- 50% of the time, the font doesn't get loaded (the page is displayed with default serif font (Times New Roman probably))
- 50% of the time, the font is loaded
How to make font loading more reliable with Selenium?
Even re-loading the page a second time with time.sleep(2); browser.get(...)
didn't help 100% of the time.