@@ -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 :
@@ -342,17 +351,6 @@ def driver_executable(request):
342351 return request .config .option .executable
343352
344353
345- def get_driver_class (driver_option ):
346- """Generate the driver class name from the lowercase driver option"""
347- if driver_option == "webkitgtk" :
348- driver_class = "WebKitGTK"
349- elif driver_option == "wpewebkit" :
350- driver_class = "WPEWebKit"
351- else :
352- driver_class = driver_option .capitalize ()
353- return driver_class
354-
355-
356354@pytest .fixture (scope = "function" )
357355def clean_service (request ):
358356 try :
0 commit comments