@@ -151,7 +151,7 @@ def __init__(self, driver_class, request):
151
151
self ._service = None
152
152
self .kwargs = {}
153
153
self .options = driver_class
154
- self .headless = driver_class
154
+ self .headless = request . config . option . headless
155
155
self .bidi = request .config .option .bidi
156
156
157
157
@property
@@ -211,17 +211,17 @@ def driver_path(self):
211
211
212
212
@property
213
213
def headless (self ):
214
- self ._headless = self ._request .config .option .headless
215
214
if self ._headless :
216
215
return True
217
216
return False
218
217
219
218
@headless .setter
220
- def headless (self , driver_class ):
221
- if self .headless :
222
- if driver_class .lower () == "chrome" or driver_class .lower () == "edge" :
219
+ def headless (self , value ):
220
+ self ._headless = value
221
+ if self ._headless :
222
+ if self .driver_class .lower () == "chrome" or self .driver_class .lower () == "edge" :
223
223
self ._options .add_argument ("--headless=new" )
224
- if driver_class .lower () == "firefox" :
224
+ if self . driver_class .lower () == "firefox" :
225
225
self ._options .add_argument ("-headless" )
226
226
227
227
@property
@@ -243,17 +243,29 @@ def options(self):
243
243
def options (self , cls_name ):
244
244
if cls_name .lower () not in self .supported_options :
245
245
raise AttributeError (f"Invalid Options class { cls_name .lower ()} " )
246
- self . _options = getattr ( webdriver , getattr ( self . supported_options , cls_name . lower ()))()
246
+
247
247
if self .driver_class == self .supported_drivers .firefox :
248
- # There are issues with window size/position when running Firefox
249
- # under Wayland, so we use XWayland instead.
250
- os .environ ["MOZ_ENABLE_WAYLAND" ] = "0"
251
- if self .driver_class == self .supported_drivers .remote :
248
+ self ._options = getattr (webdriver , self .supported_options .firefox )()
249
+ if self .exe_platform == "Linux" :
250
+ # There are issues with window size/position when running Firefox
251
+ # under Wayland, so we use XWayland instead.
252
+ os .environ ["MOZ_ENABLE_WAYLAND" ] = "0"
253
+ elif self .driver_class == self .supported_drivers .remote :
254
+ self ._options = getattr (webdriver , self .supported_options .firefox )()
252
255
self ._options .set_capability ("moz:firefoxOptions" , {})
253
256
self ._options .enable_downloads = True
254
- os .environ ["MOZ_ENABLE_WAYLAND" ] = "0"
255
- if self .driver_class == self .supported_drivers .webkitgtk :
256
- self ._options .overlay_scrollbars_enabled = False
257
+ else :
258
+ opts_cls = getattr (self .supported_options , cls_name .lower ())
259
+ self ._options = getattr (webdriver , opts_cls )()
260
+
261
+ if self .browser_path or self .browser_args :
262
+ if self .driver_class == self .supported_drivers .webkitgtk :
263
+ self ._options .overlay_scrollbars_enabled = False
264
+ if self .browser_path is not None :
265
+ self ._options .binary_location = browser_path .strip ("'" )
266
+ if self .browser_args is not None :
267
+ for arg in self .browser_args .split ():
268
+ self ._options .add_argument (arg )
257
269
258
270
@property
259
271
def service (self ):
0 commit comments