34
34
urllib3 .disable_warnings ()
35
35
DRIVER_DIR = os .path .dirname (os .path .realpath (drivers .__file__ ))
36
36
DEFAULT_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"
38
40
39
41
40
42
def invalid_run_command ():
@@ -124,7 +126,7 @@ def main():
124
126
else :
125
127
raise Exception ("Could not find Chromedriver to download!\n " )
126
128
elif name == "geckodriver" or name == "firefoxdriver" :
127
- use_version = "v0.24.0"
129
+ use_version = DEFAULT_GECKODRIVER_VERSION
128
130
if "darwin" in sys_plat :
129
131
file_name = "geckodriver-%s-macos.tar.gz" % use_version
130
132
elif "linux" in sys_plat :
@@ -142,7 +144,7 @@ def main():
142
144
download_url = ("https://github.com/mozilla/geckodriver/"
143
145
"releases/download/"
144
146
"%s/%s" % (use_version , file_name ))
145
- elif name == "edgedriver" or name == "microsoftwebdriver " :
147
+ elif name == "edgedriver" or name == "msedgedriver " :
146
148
name = "edgedriver"
147
149
use_version = DEFAULT_EDGEDRIVER_VERSION
148
150
if num_args == 4 :
@@ -175,7 +177,7 @@ def main():
175
177
"%s/%s" % (major_version , file_name ))
176
178
elif name == "operadriver" or name == "operachromiumdriver" :
177
179
name = "operadriver"
178
- use_version = "v.2.40"
180
+ use_version = DEFAULT_OPERADRIVER_VERSION
179
181
if "darwin" in sys_plat :
180
182
file_name = "operadriver_mac64.zip"
181
183
platform_code = "mac64"
@@ -235,7 +237,7 @@ def main():
235
237
if name == "operadriver" :
236
238
raise Exception ("Zip file for OperaDriver is missing content!" )
237
239
for f_name in contents :
238
- # remove existing version if exists
240
+ # Remove existing version if exists
239
241
new_file = downloads_folder + '/' + str (f_name )
240
242
if "Driver" in new_file or "driver" in new_file :
241
243
if os .path .exists (new_file ):
@@ -258,6 +260,52 @@ def main():
258
260
print ("Location of [%s %s]:\n %s" % (
259
261
f_name , use_version , new_file ))
260
262
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 ("" )
261
309
elif name == "operadriver" :
262
310
if len (contents ) != 3 :
263
311
raise Exception ("Unexpected content in OperaDriver Zip file!" )
@@ -267,7 +315,7 @@ def main():
267
315
driver_path = None
268
316
driver_file = None
269
317
for f_name in contents :
270
- # remove existing version if exists
318
+ # Remove existing version if exists
271
319
str_name = str (f_name ).split (inner_folder )[1 ]
272
320
new_file = downloads_folder + '/' + str_name
273
321
if str_name == "operadriver" or str_name == "operadriver.exe" :
@@ -292,13 +340,13 @@ def main():
292
340
print ("[%s] is now ready for use!\n " % driver_file )
293
341
print ("Location of [%s %s]:\n %s" % (
294
342
driver_file , use_version , driver_path ))
295
- # clean up extra files
343
+ # Clean up extra files
296
344
if os .path .exists (inner_driver ):
297
345
os .remove (inner_driver )
298
346
if os .path .exists (inner_sha ):
299
347
os .remove (inner_sha )
300
348
if os .path .exists (downloads_folder + '/' + inner_folder ):
301
- # only works if the directory is empty
349
+ # Only works if the directory is empty
302
350
os .rmdir (downloads_folder + '/' + inner_folder )
303
351
print ("" )
304
352
elif len (contents ) == 0 :
@@ -311,7 +359,7 @@ def main():
311
359
contents = tar .getnames ()
312
360
if len (contents ) == 1 :
313
361
for f_name in contents :
314
- # remove existing version if exists
362
+ # Remove existing version if exists
315
363
new_file = downloads_folder + '/' + str (f_name )
316
364
if "Driver" in new_file or "driver" in new_file :
317
365
if os .path .exists (new_file ):
0 commit comments