@@ -155,9 +155,10 @@ def fin():
155155 if driver_instance is None :
156156 if driver_class == "Firefox" :
157157 options = get_options (driver_class , request .config )
158- # There are issues with window size/position when running Firefox
159- # under Wayland, so we use XWayland instead.
160- os .environ ["MOZ_ENABLE_WAYLAND" ] = "0"
158+ if platform .system () == "Linux" :
159+ # There are issues with window size/position when running Firefox
160+ # under Wayland, so we use XWayland instead.
161+ os .environ ["MOZ_ENABLE_WAYLAND" ] = "0"
161162 if driver_class == "Chrome" :
162163 options = get_options (driver_class , request .config )
163164 if driver_class == "Edge" :
@@ -170,9 +171,6 @@ def fin():
170171 options = get_options ("Firefox" , request .config ) or webdriver .FirefoxOptions ()
171172 options .set_capability ("moz:firefoxOptions" , {})
172173 options .enable_downloads = True
173- # There are issues with window size/position when running Firefox
174- # under Wayland, so we use XWayland instead.
175- os .environ ["MOZ_ENABLE_WAYLAND" ] = "0"
176174 if driver_path is not None :
177175 kwargs ["service" ] = get_service (driver_class , driver_path )
178176 if options is not None :
@@ -310,6 +308,11 @@ def wait_for_server(url, timeout):
310308 "is using port {}, continuing..." .format (_port )
311309 )
312310 except Exception :
311+ remote_env = os .environ .copy ()
312+ if platform .system () == "Linux" :
313+ # There are issues with window size/position when running Firefox
314+ # under Wayland, so we use XWayland instead.
315+ remote_env ["MOZ_ENABLE_WAYLAND" ] = "0"
313316 print ("Starting the Selenium server" )
314317 process = subprocess .Popen (
315318 [
@@ -323,7 +326,8 @@ def wait_for_server(url, timeout):
323326 "true" ,
324327 "--enable-managed-downloads" ,
325328 "true" ,
326- ]
329+ ],
330+ env = remote_env ,
327331 )
328332 print (f"Selenium server running as process: { process .pid } " )
329333 assert wait_for_server (url , 10 ), f"Timed out waiting for Selenium server at { url } "
0 commit comments