13
13
seleniumbase install chromedriver
14
14
seleniumbase install geckodriver
15
15
seleniumbase install edgedriver
16
+ seleniumbase install edgedriver 84.0.522.61
17
+ seleniumbase install chromedriver 84
16
18
seleniumbase install chromedriver 84.0.4147.30
17
19
seleniumbase install chromedriver latest
18
20
seleniumbase install chromedriver -p
19
21
seleniumbase install chromedriver latest -p
20
- seleniumbase install edgedriver 84.0.522.61
21
22
Output:
22
23
Installs the chosen webdriver to seleniumbase/drivers/
23
24
(chromedriver is required for Chrome automation)
27
28
(operadriver is required for Opera Browser automation)
28
29
"""
29
30
31
+ import colorama
30
32
import os
31
33
import platform
32
34
import requests
@@ -108,18 +110,28 @@ def main(override=None):
108
110
platform_code = None
109
111
inner_folder = None
110
112
copy_to_path = False
113
+ latest_version = ""
111
114
use_version = ""
112
115
new_file = ""
113
116
f_name = ""
117
+ c1 = colorama .Fore .BLUE + colorama .Back .LIGHTCYAN_EX
118
+ c2 = colorama .Fore .BLUE + colorama .Back .LIGHTGREEN_EX
119
+ c3 = colorama .Fore .BLUE + colorama .Back .LIGHTYELLOW_EX
120
+ cr = colorama .Style .RESET_ALL
114
121
115
122
if name == "chromedriver" :
123
+ last = "https://chromedriver.storage.googleapis.com/LATEST_RELEASE"
116
124
use_version = DEFAULT_CHROMEDRIVER_VERSION
117
125
get_latest = False
126
+ get_v_latest = False
118
127
if num_args == 4 or num_args == 5 :
119
128
if "-p" not in sys .argv [3 ].lower ():
120
129
use_version = sys .argv [3 ]
121
- if use_version .lower () == "latest" :
130
+ uv_low = use_version .lower ()
131
+ if uv_low == "latest" :
122
132
get_latest = True
133
+ elif len (uv_low ) < 4 and uv_low .isdigit () and int (uv_low ) > 69 :
134
+ get_v_latest = True
123
135
else :
124
136
copy_to_path = True
125
137
if num_args == 5 :
@@ -138,20 +150,48 @@ def main(override=None):
138
150
"to download!" )
139
151
found_chromedriver = False
140
152
if get_latest :
141
- last = "http://chromedriver.storage.googleapis.com/LATEST_RELEASE"
142
153
url_request = requests .get (last )
143
154
if url_request .ok :
144
155
found_chromedriver = True
145
156
use_version = url_request .text
146
- download_url = ("http://chromedriver.storage.googleapis.com/"
157
+ elif get_v_latest :
158
+ url_req = requests .get (last )
159
+ if url_req .ok :
160
+ latest_version = url_req .text
161
+ last = last + "_" + use_version
162
+ url_request = requests .get (last )
163
+ if url_request .ok :
164
+ found_chromedriver = True
165
+ use_version = url_request .text
166
+ if use_version == latest_version :
167
+ get_latest = True
168
+ download_url = ("https://chromedriver.storage.googleapis.com/"
147
169
"%s/%s" % (use_version , file_name ))
148
170
url_request = None
149
171
if not found_chromedriver :
172
+ url_req = requests .get (last )
173
+ if url_req .ok :
174
+ latest_version = url_req .text
175
+ if use_version == latest_version :
176
+ get_latest = True
150
177
url_request = requests .get (download_url )
151
178
if found_chromedriver or url_request .ok :
152
- print ("\n * chromedriver version for download = %s" % use_version )
179
+ p_version = use_version
180
+ p_version = c3 + use_version + cr
181
+ if get_latest :
182
+ p_version = p_version + " (Latest)"
183
+ else :
184
+ p_version = p_version + " (NOT Latest)"
185
+ msg = c2 + "chromedriver version for download" + cr
186
+ print ("\n *** %s = %s" % (msg , p_version ))
153
187
else :
154
188
raise Exception ("Could not find chromedriver to download!\n " )
189
+ if not get_latest :
190
+ to_upgrade = " " + c3 + "To upgrade" + cr
191
+ run_this = c3 + "run this" + cr
192
+ install_sb = c1 + "seleniumbase install chromedriver latest" + cr
193
+ print ("\n #%s to the latest version of chromedriver," % to_upgrade )
194
+ print ('# %s: >>> %s' % (run_this , install_sb ))
155
195
elif name == "geckodriver" or name == "firefoxdriver" :
156
196
use_version = DEFAULT_GECKODRIVER_VERSION
157
197
if "win32" in sys_plat or "win64" in sys_plat or "x64" in sys_plat :
@@ -196,7 +236,9 @@ def main(override=None):
196
236
if not found_geckodriver :
197
237
url_request = requests .get (download_url )
198
238
if found_geckodriver or url_request .ok :
199
- print ("\n * geckodriver version for download = %s" % use_version )
239
+ msg = c2 + "geckodriver version for download" + cr
240
+ p_version = c3 + use_version + cr
241
+ print ("\n *** %s = %s" % (msg , p_version ))
200
242
else :
201
243
raise Exception ("\n Could not find the specified geckodriver "
202
244
"version to download!\n " )
@@ -226,6 +268,9 @@ def main(override=None):
226
268
"only for Windows or Mac operating systems!" )
227
269
download_url = ("https://msedgedriver.azureedge.net/"
228
270
"%s/%s" % (use_version , file_name ))
271
+ msg = c2 + "edgedriver version for download" + cr
272
+ p_version = c3 + use_version + cr
273
+ print ("\n *** %s = %s" % (msg , p_version ))
229
274
elif name == "iedriver" :
230
275
major_version = "3.14"
231
276
full_version = "3.14.0"
@@ -237,7 +282,7 @@ def main(override=None):
237
282
else :
238
283
raise Exception ("Sorry! IEDriver is only for "
239
284
"Windows-based operating systems!" )
240
- download_url = ("http ://selenium-release.storage.googleapis.com/"
285
+ download_url = ("https ://selenium-release.storage.googleapis.com/"
241
286
"%s/%s" % (major_version , file_name ))
242
287
elif name == "operadriver" or name == "operachromiumdriver" :
243
288
name = "operadriver"
@@ -290,6 +335,9 @@ def main(override=None):
290
335
download_url = ("https://github.com/operasoftware/operachromiumdriver/"
291
336
"releases/download/"
292
337
"%s/%s" % (use_version , file_name ))
338
+ msg = c2 + "operadriver version for download" + cr
339
+ p_version = c3 + use_version + cr
340
+ print ("\n *** %s = %s" % (msg , p_version ))
293
341
else :
294
342
invalid_run_command ()
295
343
@@ -326,15 +374,16 @@ def main(override=None):
326
374
print ('Unzip Complete!\n ' )
327
375
for f_name in contents :
328
376
new_file = downloads_folder + '/' + str (f_name )
329
- print ("The file [%s] was saved to:\n %s\n " % (f_name , new_file ))
377
+ pr_file = c3 + new_file + cr
378
+ print ("The file [%s] was saved to:\n %s\n " % (f_name , pr_file ))
330
379
print ("Making [%s %s] executable ..." % (f_name , use_version ))
331
380
make_executable (new_file )
332
- print ("[%s] is now ready for use!" % f_name )
381
+ print ("%s [%s] is now ready for use!%s " % ( c1 , f_name , cr ) )
333
382
if copy_to_path and os .path .exists (LOCAL_PATH ):
334
383
path_file = LOCAL_PATH + f_name
335
384
shutil .copyfile (new_file , path_file )
336
385
make_executable (path_file )
337
- print ("Also copied to: %s" % path_file )
386
+ print ("Also copied to: %s%s%s " % ( c3 , path_file , cr ) )
338
387
print ("" )
339
388
elif name == "edgedriver" or name == "msedgedriver" :
340
389
if "darwin" in sys_plat or "linux" in sys_plat :
@@ -364,7 +413,7 @@ def main(override=None):
364
413
if os .path .exists (new_file ):
365
414
os .remove (new_file )
366
415
if not driver_file or not driver_path :
367
- raise Exception ("Operadriver missing from Zip file!" )
416
+ raise Exception ("msedgedriver missing from Zip file!" )
368
417
print ('Extracting %s from %s ...' % (contents , file_name ))
369
418
zip_ref .extractall (downloads_folder )
370
419
zip_ref .close ()
@@ -382,7 +431,7 @@ def main(override=None):
382
431
driver_file , driver_path ))
383
432
print ("Making [%s %s] executable ..." % (driver_file , use_version ))
384
433
make_executable (driver_path )
385
- print ("[%s] is now ready for use!" % driver_file )
434
+ print ("%s [%s] is now ready for use!%s " % ( c1 , driver_file , cr ) )
386
435
print ("" )
387
436
elif name == "operadriver" :
388
437
if len (contents ) > 3 :
@@ -409,16 +458,17 @@ def main(override=None):
409
458
inner_driver = downloads_folder + '/' + inner_folder + driver_file
410
459
inner_sha = downloads_folder + '/' + inner_folder + "sha512_sum"
411
460
shutil .copyfile (inner_driver , driver_path )
461
+ pr_driver_path = c3 + driver_path + cr
412
462
print ("The file [%s] was saved to:\n %s\n " % (
413
- driver_file , driver_path ))
463
+ driver_file , pr_driver_path ))
414
464
print ("Making [%s %s] executable ..." % (driver_file , use_version ))
415
465
make_executable (driver_path )
416
- print ("[%s] is now ready for use!" % driver_file )
466
+ print ("%s [%s] is now ready for use!%s " % ( c1 , driver_file , cr ) )
417
467
if copy_to_path and os .path .exists (LOCAL_PATH ):
418
468
path_file = LOCAL_PATH + driver_file
419
469
shutil .copyfile (driver_path , path_file )
420
470
make_executable (path_file )
421
- print ("Also copied to: %s" % path_file )
471
+ print ("Also copied to: %s%s%s " % ( c3 , path_file , cr ) )
422
472
# Clean up extra files
423
473
if os .path .exists (inner_driver ):
424
474
os .remove (inner_driver )
@@ -450,15 +500,16 @@ def main(override=None):
450
500
print ('Unzip Complete!\n ' )
451
501
for f_name in contents :
452
502
new_file = downloads_folder + '/' + str (f_name )
453
- print ("The file [%s] was saved to:\n %s\n " % (f_name , new_file ))
503
+ pr_file = c3 + new_file + cr
504
+ print ("The file [%s] was saved to:\n %s\n " % (f_name , pr_file ))
454
505
print ("Making [%s %s] executable ..." % (f_name , use_version ))
455
506
make_executable (new_file )
456
- print ("[%s] is now ready for use!" % f_name )
507
+ print ("%s [%s] is now ready for use!%s " % ( c1 , f_name , cr ) )
457
508
if copy_to_path and os .path .exists (LOCAL_PATH ):
458
509
path_file = LOCAL_PATH + f_name
459
510
shutil .copyfile (new_file , path_file )
460
511
make_executable (path_file )
461
- print ("Also copied to: %s" % path_file )
512
+ print ("Also copied to: %s%s%s " % ( c3 , path_file , cr ) )
462
513
print ("" )
463
514
elif len (contents ) == 0 :
464
515
raise Exception ("Tar file %s is empty!" % tar_file_path )
@@ -469,7 +520,7 @@ def main(override=None):
469
520
if "Driver" in file_name or "driver" in file_name :
470
521
print ("Making [%s] executable ..." % file_name )
471
522
make_executable (file_path )
472
- print ("[%s] is now ready for use!" % file_name )
523
+ print ("%s [%s] is now ready for use!%s " % ( c1 , file_name , cr ) )
473
524
print ("Location of [%s]:\n %s\n " % (file_name , file_path ))
474
525
475
526
0 commit comments