Skip to content

Commit f8ad18b

Browse files
authored
[py] Fix Remote Firefox tests on Linux/Wayland (#15648)
1 parent 3d055cd commit f8ad18b

File tree

3 files changed

+14
-7
lines changed

3 files changed

+14
-7
lines changed

py/conftest.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -159,9 +159,10 @@ def fin():
159159
if driver_instance is None:
160160
if driver_class == "Firefox":
161161
options = get_options(driver_class, request.config)
162-
# There are issues with window size/position when running Firefox
163-
# under Wayland, so we use XWayland instead.
164-
os.environ["MOZ_ENABLE_WAYLAND"] = "0"
162+
if platform.system() == "Linux":
163+
# There are issues with window size/position when running Firefox
164+
# under Wayland, so we use XWayland instead.
165+
os.environ["MOZ_ENABLE_WAYLAND"] = "0"
165166
if driver_class == "Chrome":
166167
options = get_options(driver_class, request.config)
167168
if driver_class == "Edge":
@@ -174,9 +175,6 @@ def fin():
174175
options = get_options("Firefox", request.config) or webdriver.FirefoxOptions()
175176
options.set_capability("moz:firefoxOptions", {})
176177
options.enable_downloads = True
177-
# There are issues with window size/position when running Firefox
178-
# under Wayland, so we use XWayland instead.
179-
os.environ["MOZ_ENABLE_WAYLAND"] = "0"
180178
if driver_path is not None:
181179
kwargs["service"] = get_service(driver_class, driver_path)
182180
if options is not None:
@@ -315,6 +313,11 @@ def wait_for_server(url, timeout):
315313
"is using port {}, continuing...".format(_port)
316314
)
317315
except Exception:
316+
remote_env = os.environ.copy()
317+
if platform.system() == "Linux":
318+
# There are issues with window size/position when running Firefox
319+
# under Wayland, so we use XWayland instead.
320+
remote_env["MOZ_ENABLE_WAYLAND"] = "0"
318321
print("Starting the Selenium server")
319322
process = subprocess.Popen(
320323
[
@@ -328,7 +331,8 @@ def wait_for_server(url, timeout):
328331
"true",
329332
"--enable-managed-downloads",
330333
"true",
331-
]
334+
],
335+
env=remote_env,
332336
)
333337
print(f"Selenium server running as process: {process.pid}")
334338
assert wait_for_server(url, 10), f"Timed out waiting for Selenium server at {url}"

py/test/selenium/webdriver/common/api_example_tests.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,7 @@ def test_is_element_displayed(driver, pages):
239239

240240
@pytest.mark.xfail_edge
241241
@pytest.mark.xfail_firefox(reason="https://github.com/mozilla/geckodriver/issues/2224")
242+
@pytest.mark.xfail_remote(reason="https://github.com/mozilla/geckodriver/issues/2224")
242243
@pytest.mark.xfail_safari
243244
def test_move_window_position(driver, pages):
244245
pages.load("blank.html")

py/test/selenium/webdriver/common/window_tests.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ def test_should_get_the_position_of_the_current_window(driver):
6767
@pytest.mark.xfail_chrome
6868
@pytest.mark.xfail_edge
6969
@pytest.mark.xfail_firefox(reason="https://github.com/mozilla/geckodriver/issues/2224")
70+
@pytest.mark.xfail_remote(reason="https://github.com/mozilla/geckodriver/issues/2224")
7071
def test_should_set_the_position_of_the_current_window(driver):
7172
position = driver.get_window_position()
7273

@@ -94,6 +95,7 @@ def test_should_get_the_rect_of_the_current_window(driver):
9495

9596
@pytest.mark.xfail_edge
9697
@pytest.mark.xfail_firefox(reason="https://github.com/mozilla/geckodriver/issues/2224")
98+
@pytest.mark.xfail_remote(reason="https://github.com/mozilla/geckodriver/issues/2224")
9799
@pytest.mark.xfail_safari(raises=WebDriverException, reason="Get Window Rect command not implemented")
98100
def test_should_set_the_rect_of_the_current_window(driver):
99101
rect = driver.get_window_rect()

0 commit comments

Comments
 (0)