Skip to content

Commit 8322543

Browse files
committed
Install the latest EdgeDriver if not specifying a specific version
1 parent 9f6a1c4 commit 8322543

File tree

1 file changed

+22
-3
lines changed

1 file changed

+22
-3
lines changed

seleniumbase/console_scripts/sb_install.py

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@
4141
urllib3.disable_warnings()
4242
DRIVER_DIR = os.path.dirname(os.path.realpath(drivers.__file__))
4343
LOCAL_PATH = "/usr/local/bin/" # On Mac and Linux systems
44-
DEFAULT_CHROMEDRIVER_VERSION = "2.44"
44+
DEFAULT_CHROMEDRIVER_VERSION = "2.44" # (Specify "latest" to get the latest)
4545
DEFAULT_GECKODRIVER_VERSION = "v0.27.0"
46-
DEFAULT_EDGEDRIVER_VERSION = "85.0.564.44"
46+
DEFAULT_EDGEDRIVER_VERSION = "85.0.564.44" # (Looks for LATEST_STABLE first)
4747
DEFAULT_OPERADRIVER_VERSION = "v.84.0.4147.89"
4848

4949

@@ -242,19 +242,33 @@ def main(override=None):
242242
"version to download!\n")
243243
elif name == "edgedriver" or name == "msedgedriver":
244244
name = "edgedriver"
245-
use_version = DEFAULT_EDGEDRIVER_VERSION
245+
last = (
246+
"https://msedgewebdriverstorage.blob.core.windows.net"
247+
"/edgewebdriver/LATEST_STABLE")
248+
get_latest = False
249+
if num_args == 3:
250+
get_latest = True
251+
if num_args == 4 and "-p" in sys.argv[3].lower():
252+
get_latest = True
246253
if num_args == 4 or num_args == 5:
247254
if "-p" not in sys.argv[3].lower():
248255
use_version = sys.argv[3]
249256
if use_version.lower() == "latest":
250257
use_version = DEFAULT_EDGEDRIVER_VERSION
258+
get_latest = True
251259
else:
252260
copy_to_path = True
253261
if num_args == 5:
254262
if "-p" in sys.argv[4].lower():
255263
copy_to_path = True
256264
else:
257265
invalid_run_command()
266+
if get_latest:
267+
url_request = requests.get(last)
268+
if url_request.ok:
269+
use_version = url_request.text.split('\r')[0].split('\n')[0]
270+
else:
271+
use_version = DEFAULT_EDGEDRIVER_VERSION
258272
if "win64" in sys_plat or "x64" in sys_plat:
259273
file_name = "edgedriver_win64.zip"
260274
elif "win32" in sys_plat or "x86" in sys_plat:
@@ -266,6 +280,11 @@ def main(override=None):
266280
"only for Windows or Mac operating systems!")
267281
download_url = ("https://msedgedriver.azureedge.net/"
268282
"%s/%s" % (use_version, file_name))
283+
if not get_latest and not use_version == DEFAULT_EDGEDRIVER_VERSION:
284+
url_request = requests.get(download_url)
285+
if not url_request.ok:
286+
raise Exception(
287+
"Could not find version [%s] of EdgeDriver!" % use_version)
269288
msg = c2 + "edgedriver version for download" + cr
270289
p_version = c3 + use_version + cr
271290
print("\n*** %s = %s" % (msg, p_version))

0 commit comments

Comments
 (0)