|
19 | 19 | sbase get chromedriver stable |
20 | 20 | sbase get chromedriver beta |
21 | 21 | sbase get chromedriver -p |
| 22 | + sbase get chromium |
22 | 23 | sbase get cft 131 |
23 | 24 | sbase get chs |
24 | 25 | Output: |
|
46 | 47 | fromseleniumbaseimportdrivers# webdriver storage folder for SeleniumBase |
47 | 48 | fromseleniumbase.driversimportcft_drivers# chrome-for-testing |
48 | 49 | fromseleniumbase.driversimportchs_drivers# chrome-headless-shell |
| 50 | +fromseleniumbase.driversimportchromium_drivers# base chromium |
49 | 51 |
|
50 | 52 | urllib3.disable_warnings() |
51 | 53 | ARCH=platform.architecture()[0] |
52 | 54 | IS_ARM_MAC=shared_utils.is_arm_mac() |
53 | 55 | IS_MAC=shared_utils.is_mac() |
| 56 | +IS_ARM_LINUX=shared_utils.is_arm_linux() |
54 | 57 | IS_LINUX=shared_utils.is_linux() |
55 | 58 | IS_WINDOWS=shared_utils.is_windows() |
56 | 59 | DRIVER_DIR=os.path.dirname(os.path.realpath(drivers.__file__)) |
57 | 60 | DRIVER_DIR_CFT=os.path.dirname(os.path.realpath(cft_drivers.__file__)) |
58 | 61 | DRIVER_DIR_CHS=os.path.dirname(os.path.realpath(chs_drivers.__file__)) |
| 62 | +DRIVER_DIR_CHROMIUM=os.path.dirname( |
| 63 | +os.path.realpath(chromium_drivers.__file__) |
| 64 | +) |
59 | 65 | LOCAL_PATH="/usr/local/bin/"# On Mac and Linux systems |
60 | 66 | DEFAULT_CHROMEDRIVER_VERSION="114.0.5735.90"# (If can't find LATEST_STABLE) |
61 | 67 | DEFAULT_GECKODRIVER_VERSION="v0.36.0" |
@@ -203,6 +209,59 @@ def get_cft_latest_version_from_milestone(milestone): |
203 | 209 | returnurl_request.json()["milestones"][milestone]["version"] |
204 | 210 |
|
205 | 211 |
|
| 212 | +defget_chromium_channel_revision(platform_code,channel): |
| 213 | +"""Snapshots only exist for revisions where a build occurred. |
| 214 | + Therefore, not all found revisions will lead to snapshots.""" |
| 215 | +platform_key=None |
| 216 | +ifplatform_codein ["Mac_Arm","Mac"]: |
| 217 | +platform_key="Mac" |
| 218 | +elifplatform_codein ["Linux_x64"]: |
| 219 | +platform_key="Linux" |
| 220 | +elifplatform_codein ["Win_x64"]: |
| 221 | +platform_key="Windows" |
| 222 | +elifplatform_codein ["Win"]: |
| 223 | +platform_key="Win32" |
| 224 | +channel_key=None |
| 225 | +ifchannel.lower()=="stable": |
| 226 | +channel_key="Stable" |
| 227 | +elifchannel.lower()=="beta": |
| 228 | +channel_key="Beta" |
| 229 | +elifchannel.lower()=="dev": |
| 230 | +channel_key="Dev" |
| 231 | +elifchannel.lower()=="canary": |
| 232 | +channel_key="Canary" |
| 233 | +base_url="https://chromiumdash.appspot.com/fetch_releases" |
| 234 | +url=f"{base_url}?channel={channel_key}&platform={platform_key}&num=1" |
| 235 | +url_request=requests_get_with_retry(url) |
| 236 | +data=None |
| 237 | +ifurl_request.ok: |
| 238 | +data=url_request.text |
| 239 | +else: |
| 240 | +raiseException("Could not determine Chromium revision!") |
| 241 | +ifdata: |
| 242 | +try: |
| 243 | +importast |
| 244 | + |
| 245 | +result=ast.literal_eval(data) |
| 246 | +revision=result[0]["chromium_main_branch_position"] |
| 247 | +returnstr(revision) |
| 248 | +exceptException: |
| 249 | +returnget_latest_chromedriver_version(platform_code) |
| 250 | +else: |
| 251 | +returnget_latest_chromedriver_version(platform_code) |
| 252 | + |
| 253 | + |
| 254 | +defget_chromium_latest_revision(platform_code): |
| 255 | +base_url="https://storage.googleapis.com/chromium-browser-snapshots" |
| 256 | +url=f"{base_url}/{platform_code}/LAST_CHANGE" |
| 257 | +url_request=requests_get_with_retry(url) |
| 258 | +ifurl_request.ok: |
| 259 | +latest_revision=url_request.text |
| 260 | +else: |
| 261 | +raiseException("Could not determine latest Chromium revision!") |
| 262 | +returnlatest_revision |
| 263 | + |
| 264 | + |
206 | 265 | defget_latest_chromedriver_version(channel="Stable"): |
207 | 266 | try: |
208 | 267 | ifgetattr(sb_config,"cft_lkgv_json",None): |
@@ -274,6 +333,11 @@ def main(override=None, intel_for_uc=None, force_uc=None): |
274 | 333 | elifoverride.startswith("iedriver "): |
275 | 334 | extra=override.split("iedriver ")[1] |
276 | 335 | sys.argv= ["seleniumbase","get","iedriver",extra] |
| 336 | +elifoverride=="chromium": |
| 337 | +sys.argv= ["seleniumbase","get","chromium"] |
| 338 | +elifoverride.startswith("chromium "): |
| 339 | +extra=override.split("chromium ")[1] |
| 340 | +sys.argv= ["seleniumbase","get","chromium",extra] |
277 | 341 | elifoverride=="cft": |
278 | 342 | sys.argv= ["seleniumbase","get","cft"] |
279 | 343 | elifoverride.startswith("cft "): |
@@ -316,6 +380,8 @@ def main(override=None, intel_for_uc=None, force_uc=None): |
316 | 380 | downloads_folder=DRIVER_DIR_CFT |
317 | 381 | elifoverride=="chs"orname=="chs": |
318 | 382 | downloads_folder=DRIVER_DIR_CHS |
| 383 | +elifoverride=="chromium": |
| 384 | +downloads_folder=DRIVER_DIR_CHROMIUM |
319 | 385 | expected_contents=None |
320 | 386 | platform_code=None |
321 | 387 | copy_to_path=False |
@@ -643,6 +709,31 @@ def main(override=None, intel_for_uc=None, force_uc=None): |
643 | 709 | "https://storage.googleapis.com/chrome-for-testing-public/" |
644 | 710 | "%s/%s/%s"% (use_version,platform_code,file_name) |
645 | 711 | ) |
| 712 | +elifname=="chromium": |
| 713 | +ifIS_MAC: |
| 714 | +ifIS_ARM_MAC: |
| 715 | +platform_code="Mac_Arm" |
| 716 | +else: |
| 717 | +platform_code="Mac" |
| 718 | +file_name="chrome-mac.zip" |
| 719 | +elifIS_LINUX: |
| 720 | +platform_code="Linux_x64" |
| 721 | +file_name="chrome-linux.zip" |
| 722 | +elifIS_WINDOWS: |
| 723 | +if"64"inARCH: |
| 724 | +platform_code="Win_x64" |
| 725 | +else: |
| 726 | +platform_code="Win" |
| 727 | +file_name="chrome-win.zip" |
| 728 | +revision=get_chromium_latest_revision(platform_code) |
| 729 | +msg=c2+"Chromium revision to download"+cr |
| 730 | +p_version=c3+revision+cr |
| 731 | +log_d("\n*** %s = %s"% (msg,p_version)) |
| 732 | +download_url= ( |
| 733 | +"https://storage.googleapis.com/chromium-browser-snapshots/" |
| 734 | +"%s/%s/%s"% (platform_code,revision,file_name) |
| 735 | + ) |
| 736 | +downloads_folder=DRIVER_DIR_CHROMIUM |
646 | 737 | elifname=="chrome-headless-shell"orname=="chs": |
647 | 738 | set_version=None |
648 | 739 | found_version=None |
@@ -1003,12 +1094,12 @@ def main(override=None, intel_for_uc=None, force_uc=None): |
1003 | 1094 | remote_file=requests_get_with_retry(download_url) |
1004 | 1095 | withopen(file_path,"wb")asfile: |
1005 | 1096 | file.write(remote_file.content) |
1006 | | -log_d("%sDownload Complete!%s\n"% (c1,cr)) |
1007 | 1097 |
|
1008 | 1098 | iffile_name.endswith(".zip"): |
1009 | 1099 | zip_file_path=file_path |
1010 | 1100 | zip_ref=zipfile.ZipFile(zip_file_path,"r") |
1011 | 1101 | contents=zip_ref.namelist() |
| 1102 | +log_d("%sDownload Complete!%s\n"% (c1,cr)) |
1012 | 1103 | if ( |
1013 | 1104 | len(contents)>=1 |
1014 | 1105 | andnamein ["chromedriver","uc_driver","geckodriver"] |
@@ -1249,6 +1340,48 @@ def main(override=None, intel_for_uc=None, force_uc=None): |
1249 | 1340 | "Chrome for Testing was saved inside:\n%s%s\n%s\n" |
1250 | 1341 | % (pr_base_path,pr_sep,pr_folder_name) |
1251 | 1342 | ) |
| 1343 | +elifname=="chromium": |
| 1344 | +# Zip file is valid. Proceed. |
| 1345 | +driver_path=None |
| 1346 | +driver_file=None |
| 1347 | +base_path=os.sep.join(zip_file_path.split(os.sep)[:-1]) |
| 1348 | +folder_name=contents[0].split("/")[0] |
| 1349 | +folder_path=os.path.join(base_path,folder_name) |
| 1350 | +ifIS_MACorIS_LINUX: |
| 1351 | +if ( |
| 1352 | +"chromium"infolder_path |
| 1353 | +and"drivers"infolder_path |
| 1354 | +andos.path.exists(folder_path) |
| 1355 | + ): |
| 1356 | +shutil.rmtree(folder_path) |
| 1357 | +subprocess.run( |
| 1358 | + ["unzip",zip_file_path,"-d",downloads_folder] |
| 1359 | + ) |
| 1360 | +elifIS_WINDOWS: |
| 1361 | +subprocess.run( |
| 1362 | + [ |
| 1363 | +"powershell", |
| 1364 | +"Expand-Archive", |
| 1365 | +"-Path", |
| 1366 | +zip_file_path, |
| 1367 | +"-DestinationPath", |
| 1368 | +downloads_folder, |
| 1369 | +"-Force", |
| 1370 | + ] |
| 1371 | + ) |
| 1372 | +else: |
| 1373 | +zip_ref.extractall(downloads_folder) |
| 1374 | +zip_ref.close() |
| 1375 | +withsuppress(Exception): |
| 1376 | +os.remove(zip_file_path) |
| 1377 | +log_d("%sUnzip Complete!%s\n"% (c2,cr)) |
| 1378 | +pr_base_path=c3+base_path+cr |
| 1379 | +pr_sep=c3+os.sep+cr |
| 1380 | +pr_folder_name=c3+folder_name+cr |
| 1381 | +log_d( |
| 1382 | +"Chromium was saved inside:\n%s%s\n%s\n" |
| 1383 | +% (pr_base_path,pr_sep,pr_folder_name) |
| 1384 | + ) |
1252 | 1385 | elifname=="chrome-headless-shell"orname=="chs": |
1253 | 1386 | # Zip file is valid. Proceed. |
1254 | 1387 | driver_path=None |
@@ -1300,6 +1433,7 @@ def main(override=None, intel_for_uc=None, force_uc=None): |
1300 | 1433 | tar=tarfile.open(file_path) |
1301 | 1434 | contents=tar.getnames() |
1302 | 1435 | iflen(contents)==1: |
| 1436 | +log_d("%sDownload Complete!%s\n"% (c1,cr)) |
1303 | 1437 | forf_nameincontents: |
1304 | 1438 | # Remove existing version if exists |
1305 | 1439 | new_file=os.path.join(downloads_folder,str(f_name)) |
@@ -1337,6 +1471,7 @@ def main(override=None, intel_for_uc=None, force_uc=None): |
1337 | 1471 | else: |
1338 | 1472 | # Not a .zip file or a .tar.gz file. Just a direct download. |
1339 | 1473 | if"Driver"infile_nameor"driver"infile_name: |
| 1474 | +log_d("%sDownload Complete!%s\n"% (c1,cr)) |
1340 | 1475 | log_d("Making [%s] executable ..."%file_name) |
1341 | 1476 | make_executable(file_path) |
1342 | 1477 | log_d("%s[%s] is now ready for use!%s"% (c1,file_name,cr)) |
|