@@ -97,6 +97,17 @@ def pytest_ignore_collect(path, config):
9797    return  len ([d  for  d  in  _drivers  if  d .lower () in  parts ]) >  0 
9898
9999
100+ def  get_driver_class (driver_option ):
101+     """Generate the driver class name from the lowercase driver option""" 
102+     if  driver_option  ==  "webkitgtk" :
103+         driver_class  =  "WebKitGTK" 
104+     elif  driver_option  ==  "wpewebkit" :
105+         driver_class  =  "WPEWebKit" 
106+     else :
107+         driver_class  =  driver_option .capitalize ()
108+     return  driver_class 
109+ 
110+ 
100111driver_instance  =  None 
101112
102113
@@ -105,7 +116,7 @@ def driver(request):
105116    kwargs  =  {}
106117
107118    # browser can be changed with `--driver=firefox` as an argument or to addopts in pytest.ini 
108-     driver_class  =  getattr (request , "param" , "Chrome" ). capitalize ( )
119+     driver_class  =  get_driver_class ( getattr (request , "param" , "Chrome" ))
109120
110121    # skip tests if not available on the platform 
111122    _platform  =  platform .system ()
@@ -146,18 +157,16 @@ def fin():
146157            options  =  get_options (driver_class , request .config )
147158        if  driver_class  ==  "Chrome" :
148159            options  =  get_options (driver_class , request .config )
160+         if  driver_class  ==  "Edge" :
161+             options  =  get_options (driver_class , request .config )
162+         if  driver_class  ==  "WebKitGTK" :
163+             options  =  get_options (driver_class , request .config )
164+         if  driver_class .lower () ==  "WPEWebKit" :
165+             options  =  get_options (driver_class , request .config )
149166        if  driver_class  ==  "Remote" :
150167            options  =  get_options ("Firefox" , request .config ) or  webdriver .FirefoxOptions ()
151168            options .set_capability ("moz:firefoxOptions" , {})
152169            options .enable_downloads  =  True 
153-         if  driver_class .lower () ==  "webkitgtk" :
154-             driver_class  =  "WebKitGTK" 
155-             options  =  get_options (driver_class , request .config )
156-         if  driver_class  ==  "Edge" :
157-             options  =  get_options (driver_class , request .config )
158-         if  driver_class .lower () ==  "wpewebkit" :
159-             driver_class  =  "WPEWebKit" 
160-             options  =  get_options (driver_class , request .config )
161170        if  driver_path  is  not   None :
162171            kwargs ["service" ] =  get_service (driver_class , driver_path )
163172        if  options  is  not   None :
@@ -345,19 +354,19 @@ def driver_executable(request):
345354@pytest .fixture (scope = "function" ) 
346355def  clean_service (request ):
347356    try :
348-         driver_class  =  request .config .option .drivers [0 ]. capitalize ( )
349-     except  AttributeError :
350-         raise  Exception ("This test requires a --driver to be specified. " )
357+         driver_class  =  get_driver_class ( request .config .option .drivers [0 ])
358+     except  ( AttributeError ,  TypeError ) :
359+         raise  Exception ("This test requires a --driver to be specified" )
351360
352361    yield  get_service (driver_class , request .config .option .executable )
353362
354363
355364@pytest .fixture (scope = "function" ) 
356365def  clean_driver (request ):
357366    try :
358-         driver_class  =  request .config .option .drivers [0 ]. capitalize ( )
359-     except  AttributeError :
360-         raise  Exception ("This test requires a --driver to be specified. " )
367+         driver_class  =  get_driver_class ( request .config .option .drivers [0 ])
368+     except  ( AttributeError ,  TypeError ) :
369+         raise  Exception ("This test requires a --driver to be specified" )
361370
362371    driver_reference  =  getattr (webdriver , driver_class )
363372    yield  driver_reference 
0 commit comments