Skip to content

Commit

Permalink
Merge pull request #59 from penpot/chrome-renderer-headless-parameter
Browse files Browse the repository at this point in the history
Allow setting headlessness for chrome web driver creation
  • Loading branch information
kklemon authored Jun 6, 2024
2 parents feabe58 + cd810ea commit f5743b6
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/penai/utils/web_drivers.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,16 @@


@contextmanager
def create_chrome_web_driver() -> Generator[WebDriver, Any, Any]:
def create_chrome_web_driver(headless: bool = True) -> Generator[WebDriver, Any, Any]:
"""Helper function to instantiate a Chrome WebDriver instance with all options we need."""
driver = None

try:
chrome_options = Options()
chrome_options.add_argument("--headless")

if headless:
chrome_options.add_argument("--headless")

chrome_options.add_argument("--disable-gpu")

# The screenshot size might deviate from the actual SVG size on high-dpi devices with a device scale factor != 1.0
Expand Down

0 comments on commit f5743b6

Please sign in to comment.