3434urllib3 .disable_warnings ()
3535DRIVER_DIR = os .path .dirname (os .path .realpath (drivers .__file__ ))
3636DEFAULT_CHROMEDRIVER_VERSION = "2.44"
37- DEFAULT_EDGEDRIVER_VERSION = "78.0.268.0"
37+ DEFAULT_GECKODRIVER_VERSION = "v0.24.0"
38+ DEFAULT_EDGEDRIVER_VERSION = "77.0.235.20"
39+ DEFAULT_OPERADRIVER_VERSION = "v.2.40"
3840
3941
4042def invalid_run_command ():
@@ -124,7 +126,7 @@ def main():
124126 else :
125127 raise Exception ("Could not find Chromedriver to download!\n " )
126128 elif name == "geckodriver" or name == "firefoxdriver" :
127- use_version = "v0.24.0"
129+ use_version = DEFAULT_GECKODRIVER_VERSION
128130 if "darwin" in sys_plat :
129131 file_name = "geckodriver-%s-macos.tar.gz" % use_version
130132 elif "linux" in sys_plat :
@@ -142,7 +144,7 @@ def main():
142144 download_url = ("https://github.com/mozilla/geckodriver/"
143145 "releases/download/"
144146 "%s/%s" % (use_version , file_name ))
145- elif name == "edgedriver" or name == "microsoftwebdriver " :
147+ elif name == "edgedriver" or name == "msedgedriver " :
146148 name = "edgedriver"
147149 use_version = DEFAULT_EDGEDRIVER_VERSION
148150 if num_args == 4 :
@@ -175,7 +177,7 @@ def main():
175177 "%s/%s" % (major_version , file_name ))
176178 elif name == "operadriver" or name == "operachromiumdriver" :
177179 name = "operadriver"
178- use_version = "v.2.40"
180+ use_version = DEFAULT_OPERADRIVER_VERSION
179181 if "darwin" in sys_plat :
180182 file_name = "operadriver_mac64.zip"
181183 platform_code = "mac64"
@@ -235,7 +237,7 @@ def main():
235237 if name == "operadriver" :
236238 raise Exception ("Zip file for OperaDriver is missing content!" )
237239 for f_name in contents :
238- # remove existing version if exists
240+ # Remove existing version if exists
239241 new_file = downloads_folder + '/' + str (f_name )
240242 if "Driver" in new_file or "driver" in new_file :
241243 if os .path .exists (new_file ):
@@ -258,6 +260,52 @@ def main():
258260 print ("Location of [%s %s]:\n %s" % (
259261 f_name , use_version , new_file ))
260262 print ("" )
263+ elif name == "edgedriver" or name == "msedgedriver" :
264+ if "darwin" in sys_plat or "linux" in sys_plat :
265+ raise Exception ("Unexpected file format for msedgedriver!" )
266+ expected_contents = (['Driver_Notes/' ,
267+ 'Driver_Notes/credits.html' ,
268+ 'Driver_Notes/LICENSE' ,
269+ 'msedgedriver.exe' ])
270+ if len (contents ) != 4 :
271+ raise Exception ("Unexpected content in EdgeDriver Zip file!" )
272+ # Zip file is valid. Proceed.
273+ driver_path = None
274+ driver_file = None
275+ for f_name in contents :
276+ print (f_name )
277+ # Remove existing version if exists
278+ str_name = str (f_name )
279+ new_file = downloads_folder + '/' + str_name
280+ if str_name == "msedgedriver.exe" :
281+ driver_file = str_name
282+ driver_path = new_file
283+ if os .path .exists (new_file ):
284+ os .remove (new_file )
285+ if not driver_file or not driver_path :
286+ raise Exception ("Operadriver missing from Zip file!" )
287+ print ('Extracting %s from %s ...' % (contents , file_name ))
288+ zip_ref .extractall (downloads_folder )
289+ zip_ref .close ()
290+ os .remove (zip_file_path )
291+ print ('Unzip Complete!\n ' )
292+ to_remove = (['%s/Driver_Notes/credits.html' % downloads_folder ,
293+ '%s/Driver_Notes/LICENSE' % downloads_folder ])
294+ for file_to_remove in to_remove :
295+ if os .path .exists (file_to_remove ):
296+ os .remove (file_to_remove )
297+ if os .path .exists (downloads_folder + '/' + "Driver_Notes/" ):
298+ # Only works if the directory is empty
299+ os .rmdir (downloads_folder + '/' + "Driver_Notes/" )
300+ print ("The file [%s] was saved to:\n %s\n " % (
301+ driver_file , driver_path ))
302+ print ("Making [%s] executable ..." % driver_file )
303+ make_executable (driver_path )
304+ print ("[%s] is now ready for use!\n " % driver_file )
305+ print ("Add folder path of Edge to System Environmental Variables!" )
306+ print ("\n Location of [%s %s]:\n %s" % (
307+ driver_file , use_version , driver_path ))
308+ print ("" )
261309 elif name == "operadriver" :
262310 if len (contents ) != 3 :
263311 raise Exception ("Unexpected content in OperaDriver Zip file!" )
@@ -267,7 +315,7 @@ def main():
267315 driver_path = None
268316 driver_file = None
269317 for f_name in contents :
270- # remove existing version if exists
318+ # Remove existing version if exists
271319 str_name = str (f_name ).split (inner_folder )[1 ]
272320 new_file = downloads_folder + '/' + str_name
273321 if str_name == "operadriver" or str_name == "operadriver.exe" :
@@ -292,13 +340,13 @@ def main():
292340 print ("[%s] is now ready for use!\n " % driver_file )
293341 print ("Location of [%s %s]:\n %s" % (
294342 driver_file , use_version , driver_path ))
295- # clean up extra files
343+ # Clean up extra files
296344 if os .path .exists (inner_driver ):
297345 os .remove (inner_driver )
298346 if os .path .exists (inner_sha ):
299347 os .remove (inner_sha )
300348 if os .path .exists (downloads_folder + '/' + inner_folder ):
301- # only works if the directory is empty
349+ # Only works if the directory is empty
302350 os .rmdir (downloads_folder + '/' + inner_folder )
303351 print ("" )
304352 elif len (contents ) == 0 :
@@ -311,7 +359,7 @@ def main():
311359 contents = tar .getnames ()
312360 if len (contents ) == 1 :
313361 for f_name in contents :
314- # remove existing version if exists
362+ # Remove existing version if exists
315363 new_file = downloads_folder + '/' + str (f_name )
316364 if "Driver" in new_file or "driver" in new_file :
317365 if os .path .exists (new_file ):
0 commit comments