Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow setting headlessness for chrome web driver creation #59

Merged
merged 1 commit into from
Jun 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading