Skip to content

Commit 7b5c542

Browse files
committed
Update the webdriver installer script (for Chrome and Firefox)
1 parent e003980 commit 7b5c542

File tree

1 file changed

+26
-34
lines changed

1 file changed

+26
-34
lines changed

seleniumbase/console_scripts/sb_install.py

Lines changed: 26 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
iedriver|operadriver} [OPTIONS]
77
Options:
88
VERSION Specify the version.
9-
(Default Chromedriver version = 2.44)
9+
(Default chromedriver version = 2.44)
1010
Use "latest" for the latest version.
1111
-p OR --path Also copy the driver to /usr/local/bin
1212
Example:
@@ -51,7 +51,7 @@ def invalid_run_command():
5151
exp += " iedriver, operadriver)\n"
5252
exp += " Options:\n"
5353
exp += " VERSION Specify the version.\n"
54-
exp += " (Default Chromedriver version = 2.44)\n"
54+
exp += " (Default chromedriver version = 2.44)\n"
5555
exp += ' Use "latest" for the latest version.\n'
5656
exp += " -p OR --path Also copy the driver to /usr/local/bin\n"
5757
exp += " Example:\n"
@@ -79,7 +79,12 @@ def make_executable(file_path):
7979
os.chmod(file_path, mode)
8080

8181

82-
def main():
82+
def main(override=None):
83+
if override == "chromedriver":
84+
sys.argv = ["seleniumbase", "install", "chromedriver"]
85+
if override == "geckodriver":
86+
sys.argv = ["seleniumbase", "install", "geckodriver"]
87+
8388
num_args = len(sys.argv)
8489
if sys.argv[0].split('/')[-1].lower() == "seleniumbase" or (
8590
sys.argv[0].split('\\')[-1].lower() == "seleniumbase"):
@@ -123,7 +128,7 @@ def main():
123128
elif "win32" in sys_plat or "win64" in sys_plat or "x64" in sys_plat:
124129
file_name = "chromedriver_win32.zip" # Works for win32 / win_x64
125130
else:
126-
raise Exception("Cannot determine which version of Chromedriver "
131+
raise Exception("Cannot determine which version of chromedriver "
127132
"to download!")
128133
found_chromedriver = False
129134
if get_latest:
@@ -138,9 +143,9 @@ def main():
138143
if not found_chromedriver:
139144
url_request = requests.get(download_url)
140145
if found_chromedriver or url_request.ok:
141-
print("\nChromedriver version for download = %s" % use_version)
146+
print("\n* chromedriver version for download = %s" % use_version)
142147
else:
143-
raise Exception("Could not find Chromedriver to download!\n")
148+
raise Exception("Could not find chromedriver to download!\n")
144149
elif name == "geckodriver" or name == "firefoxdriver":
145150
use_version = DEFAULT_GECKODRIVER_VERSION
146151
found_geckodriver = False
@@ -174,7 +179,7 @@ def main():
174179
elif "win32" in sys_plat or "win64" in sys_plat or "x64" in sys_plat:
175180
file_name = "geckodriver-%s-win64.zip" % use_version
176181
else:
177-
raise Exception("Cannot determine which version of Geckodriver "
182+
raise Exception("Cannot determine which version of geckodriver "
178183
"(Firefox Driver) to download!")
179184
download_url = ("https://github.com/mozilla/geckodriver/"
180185
"releases/download/"
@@ -183,9 +188,9 @@ def main():
183188
if not found_geckodriver:
184189
url_request = requests.get(download_url)
185190
if found_geckodriver or url_request.ok:
186-
print("\nGeckodriver version for download = %s" % use_version)
191+
print("\n* geckodriver version for download = %s" % use_version)
187192
else:
188-
raise Exception("\nCould not find the specified Geckodriver "
193+
raise Exception("\nCould not find the specified geckodriver "
189194
"version to download!\n")
190195
elif name == "edgedriver" or name == "msedgedriver":
191196
name = "edgedriver"
@@ -314,18 +319,13 @@ def main():
314319
for f_name in contents:
315320
new_file = downloads_folder + '/' + str(f_name)
316321
print("The file [%s] was saved to:\n%s\n" % (f_name, new_file))
317-
print("Making [%s] executable ..." % f_name)
322+
print("Making [%s %s] executable ..." % (f_name, use_version))
318323
make_executable(new_file)
319-
print("[%s] is now ready for use!\n" % f_name)
320-
print('(If running on a Selenium Grid, copy [%s] to your '
321-
'System PATH.\n'
322-
' E.g. to the "/usr/local/bin/" folder on Linux '
323-
'systems.)\n' % name)
324-
print("Location of [%s %s]:\n%s" % (
325-
f_name, use_version, new_file))
324+
print("[%s] is now ready for use!" % f_name)
326325
if copy_to_path and os.path.exists(LOCAL_PATH):
327326
path_file = LOCAL_PATH + f_name
328327
shutil.copyfile(new_file, path_file)
328+
make_executable(path_file)
329329
print("Also copied to: %s" % path_file)
330330
print("")
331331
elif name == "edgedriver" or name == "msedgedriver":
@@ -367,12 +367,10 @@ def main():
367367
os.rmdir(downloads_folder + '/' + "Driver_Notes/")
368368
print("The file [%s] was saved to:\n%s\n" % (
369369
driver_file, driver_path))
370-
print("Making [%s] executable ..." % driver_file)
370+
print("Making [%s %s] executable ..." % (driver_file, use_version))
371371
make_executable(driver_path)
372-
print("[%s] is now ready for use!\n" % driver_file)
372+
print("[%s] is now ready for use!" % driver_file)
373373
print("Add folder path of Edge to System Environmental Variables!")
374-
print("\nLocation of [%s %s]:\n%s" % (
375-
driver_file, use_version, driver_path))
376374
print("")
377375
elif name == "operadriver":
378376
if len(contents) != 3:
@@ -403,14 +401,13 @@ def main():
403401
shutil.copyfile(inner_driver, driver_path)
404402
print("The file [%s] was saved to:\n%s\n" % (
405403
driver_file, driver_path))
406-
print("Making [%s] executable ..." % driver_file)
404+
print("Making [%s %s] executable ..." % (driver_file, use_version))
407405
make_executable(driver_path)
408-
print("[%s] is now ready for use!\n" % driver_file)
409-
print("Location of [%s %s]:\n%s" % (
410-
driver_file, use_version, driver_path))
406+
print("[%s] is now ready for use!" % driver_file)
411407
if copy_to_path and os.path.exists(LOCAL_PATH):
412408
path_file = LOCAL_PATH + driver_file
413409
shutil.copyfile(driver_path, path_file)
410+
make_executable(path_file)
414411
print("Also copied to: %s" % path_file)
415412
# Clean up extra files
416413
if os.path.exists(inner_driver):
@@ -444,18 +441,13 @@ def main():
444441
for f_name in contents:
445442
new_file = downloads_folder + '/' + str(f_name)
446443
print("The file [%s] was saved to:\n%s\n" % (f_name, new_file))
447-
print("Making [%s] executable ..." % f_name)
444+
print("Making [%s %s] executable ..." % (f_name, use_version))
448445
make_executable(new_file)
449-
print("[%s] is now ready for use!\n" % f_name)
450-
print('(If running on a Selenium Grid, copy [%s] to your '
451-
'System PATH.\n'
452-
' E.g. to the "/usr/local/bin/" folder on Linux '
453-
'systems.)\n' % name)
454-
print("Location of [%s %s]:\n%s" % (
455-
f_name, use_version, new_file))
446+
print("[%s] is now ready for use!" % f_name)
456447
if copy_to_path and os.path.exists(LOCAL_PATH):
457448
path_file = LOCAL_PATH + f_name
458449
shutil.copyfile(new_file, path_file)
450+
make_executable(path_file)
459451
print("Also copied to: %s" % path_file)
460452
print("")
461453
elif len(contents) == 0:
@@ -467,7 +459,7 @@ def main():
467459
if "Driver" in file_name or "driver" in file_name:
468460
print("Making [%s] executable ..." % file_name)
469461
make_executable(file_path)
470-
print("[%s] is now ready for use!\n" % file_name)
462+
print("[%s] is now ready for use!" % file_name)
471463
print("Location of [%s]:\n%s\n" % (file_name, file_path))
472464

473465

0 commit comments

Comments
 (0)