Skip to content

Commit 24ce87e

Browse files
committed
run chrome tests with CI compatibility tweaks
1 parent 51625fb commit 24ce87e

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

tests/conftest.py

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# import os
2-
# import shutil
31
import contextlib
42
import os
53
from typing import TYPE_CHECKING, cast
@@ -35,7 +33,6 @@ def example_html() -> str:
3533
params=[
3634
"chrome-headless",
3735
"chrome",
38-
# "chrome-custom-path",
3936
"firefox-headless",
4037
pytest.param("firefox", marks=pytest.mark.skipif(os.getenv("CI") == "true", reason="Non-headless Firefox unreliable in CI")),
4138
]
@@ -46,15 +43,14 @@ def session(request): # noqa: ANN001, ANN201
4643
if driver_type == "chrome-headless":
4744
options = webdriver.ChromeOptions()
4845
options.add_argument("--headless=new")
46+
options.add_argument("--no-sandbox") # Helps when running on Github Actions
47+
options.add_argument("--disable-dev-shm-usage") # Helps when running on Github Actions
4948
driver = webdriver.Chrome(options=options)
5049
elif driver_type == "chrome":
51-
driver = webdriver.Chrome()
52-
# elif driver_type == "chrome-custom-path":
53-
# chromedriver_name = "chromedriver"
54-
# custom_path = shutil.which(chromedriver_name)
55-
# assert custom_path, f"'{chromedriver_name}' not found in PATH."
56-
# assert os.path.exists(custom_path), f"Custom chromedriver not found at {custom_path}."
57-
# driver = webdriver.Chrome(service=webdriver.ChromeService(executable_path=custom_path))
50+
options = webdriver.ChromeOptions()
51+
options.add_argument("--no-sandbox") # Helps when running on Github Actions
52+
options.add_argument("--disable-dev-shm-usage") # Helps when running on Github Actions
53+
driver = webdriver.Chrome(options=options)
5854
elif driver_type == "firefox-headless":
5955
options = webdriver.FirefoxOptions()
6056
options.add_argument("--headless")

0 commit comments

Comments
 (0)