Skip to content

Commit

Permalink
Run Firefox non-headless, for debugging purposes
Browse files Browse the repository at this point in the history
  • Loading branch information
amotl committed Apr 15, 2024
1 parent 342b524 commit feb7f5d
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions imagecast/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,26 @@ def capture(self, uri: str, dom_selector: str = None) -> bytes:
from playwright.sync_api import sync_playwright
tmpfile = tempfile.NamedTemporaryFile(suffix=".png")
with sync_playwright() as p:
browser = p.firefox.launch()
browser = p.firefox.launch(
headless=False,
firefox_user_prefs={
"network.cookie.cookieBehavior": 4,
"security.insecure_field_warning.contextual.enabled": False,
"security.certerrors.permanentOverride": False,
"network.stricttransportsecurity.preloadlist": False,
"security.enterprise_roots.enabled": True,
"security.mixed_content.block_active_content": False,
})
page = browser.new_page()
page.goto(uri)
#page.wait_for_load_state("commit")
page.wait_for_load_state("networkidle")
element = page
if dom_selector:
element = page.locator(dom_selector)
element.wait_for(timeout=300000)
element.screenshot(path=tmpfile.name)
browser.close()
#browser.close()
return tmpfile.read()

def download(self, uri):
Expand Down

0 comments on commit feb7f5d

Please sign in to comment.