2222import pytest
2323
2424from selenium import webdriver
25+ from selenium .webdriver .firefox .options import Options
2526
2627
2728def is_running_wayland ():
@@ -31,12 +32,15 @@ def is_running_wayland():
3132
3233
3334@pytest .mark .skipif (not is_running_wayland (), reason = "This test only runs on Linux under Wayland" )
34- def test_firefox_opens_large_when_running_xwayland ():
35+ def test_firefox_opens_large_when_running_xwayland (request ):
36+ options = Options ()
37+ if request .config .getoption ("--headless" ):
38+ options .add_argument ("-headless" )
3539 # setting environment variable `MOZ_ENABLE_WAYLAND=0` forces Firefox
3640 # to run under XWayland on Wayland based systems
3741 with patch .dict ("os.environ" , {"MOZ_ENABLE_WAYLAND" : "0" }):
3842 try :
39- driver = webdriver .Firefox ()
43+ driver = webdriver .Firefox (options = options )
4044 size = driver .get_window_size ()
4145 assert size ["height" ] > 500
4246 assert size ["width" ] > 500
@@ -48,8 +52,11 @@ def test_firefox_opens_large_when_running_xwayland():
4852@pytest .mark .xfail (reason = "https://bugzilla.mozilla.org/show_bug.cgi?id=1959040" )
4953# Firefox opens in a small window when running on Linux/Wayland
5054def test_firefox_opens_large_when_running_wayland ():
55+ options = Options ()
56+ if request .config .getoption ("--headless" ):
57+ options .add_argument ("-headless" )
5158 try :
52- driver = webdriver .Firefox ()
59+ driver = webdriver .Firefox (options = options )
5360 size = driver .get_window_size ()
5461 assert size ["height" ] > 500
5562 assert size ["width" ] > 500
0 commit comments