@@ -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 } "
0 commit comments