From 2ee626a0e88b5395d4edfde90d86a5d68514cad8 Mon Sep 17 00:00:00 2001 From: Joshua Fehler Date: Mon, 24 Jun 2024 09:03:58 -0400 Subject: [PATCH] tests: Ensure disable-dev-shm-usage is set for chromium, retry edge tests --- .github/workflows/windows.yml | 3 ++- tests/conftest.py | 24 ++++++++++++++++-------- tox.ini | 1 - 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index 01334dd5e..dc0045e9f 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -44,4 +44,5 @@ jobs: - name: Run tests for windows-only drivers run: | - tox -e tests_selenium_edge -- -n 4; + tox -e tests_selenium_edge -- --cache-clear -n 4 || tox -e tests_selenium_edge -- -n 1 --last-failed --last-failed-no-failures none + tox -e tests_selenium_edge -- --cache-clear --webdriver-fullscreen True -n 4 || tox -e tests_selenium_edge -- --webdriver-fullscreen True -n 1 --last-failed --last-failed-no-failures none diff --git a/tests/conftest.py b/tests/conftest.py index c5f62c97d..eb6d452b4 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -130,23 +130,35 @@ def browser_config(request): def browser_kwargs(request): option = request.config.option + kwargs = {} + if option.webdriver_remote_name: - return {"browser": request.config.option.webdriver_remote_name} + kwargs = {"browser": request.config.option.webdriver_remote_name} if option.browser_name == "flask": from tests.fake_webapp import app - return {"app": app, "wait_time": 0.1} + kwargs = {"app": app, "wait_time": 0.1} if option.browser_name == "django": components = parse.urlparse("http://127.0.0.1:5000/") - return { + kwargs = { "wait_time": 0.1, "client_SERVER_NAME": components.hostname, "client_SERVER_PORT": components.port, } - return {} + wd_options = None + if (browser_name == "chrome") or (option.webdriver_remote_name == "chrome"): + wd_options = webdriver.chrome.options.Options() + wd_options.add_argument("--disable-dev-shm-usage") + kwargs["options"] = wd_options + elif browser_name == "edge" or (option.webdriver_remote_name == "edge"): + wd_options = webdriver.edge.options.Options() + wd_options.add_argument("--disable-dev-shm-usage") + kwargs["options"] = wd_options + + return kwargs @pytest.fixture(scope="function") @@ -158,10 +170,6 @@ def browser(browser_name, browser_config, browser_kwargs, request): if browser_name in ["chrome", "firefox", "edge"]: b.driver.set_window_size(1024, 768) - if browser_name == "chrome": - options = webdriver.chrome.options.Options() - options.add_argument("--disable-dev-shm-usage") - return b diff --git a/tox.ini b/tox.ini index 2961a2e0d..6c3ae6599 100644 --- a/tox.ini +++ b/tox.ini @@ -48,7 +48,6 @@ passenv = EDGEWEBDRIVER commands = pytest --ignore-flaky {posargs} --browser=edge tests/test_all_drivers tests/tests_webdriver tests/tests_webdriver_local - pytest --ignore-flaky {posargs} --browser=edge --webdriver-fullscreen True tests/test_all_drivers tests/tests_webdriver tests/tests_webdriver_local [testenv:tests_selenium_remote_chrome] extras = selenium