From 7afb2274a2f86b09024266ac5e80816886fbb720 Mon Sep 17 00:00:00 2001 From: yuriy Date: Sun, 20 Aug 2023 01:20:16 -0400 Subject: [PATCH] added function to get latest stable chrome version, function to get URLs for chrome and chromedriver for that given version --- Chrome-Functions.ahk | 44 ++++++++++++++++++++++++++++++++++---------- 1 file changed, 34 insertions(+), 10 deletions(-) diff --git a/Chrome-Functions.ahk b/Chrome-Functions.ahk index 5b1c26e..0b73a39 100644 --- a/Chrome-Functions.ahk +++ b/Chrome-Functions.ahk @@ -59,7 +59,28 @@ GetChromeVersion(){ } -GetURLofLatestChromedriver(ChromeVersion){ +GetLatestChromeStableVersion(){ + + ; https://github.com/GoogleChromeLabs/chrome-for-testing#json-api-endpoints + json_str := urldownloadtovar("https://googlechromelabs.github.io/chrome-for-testing/last-known-good-versions.json") + + + ; converts json data variable into object + parsed := JSON.Load(json_str) + + + try CurrentChromeStableVersion := parsed.channels.stable.version + + if(CurrentChromeStableVersion = ""){ + return "Failed to parse json. " + } + + return CurrentChromeStableVersion +} + + +GetDownloadURLOfChromeAndDriver(ChromeVersion){ + ; Will return the download URL of Chrome for Testing and Chrome Driver, seperated by a || ; https://github.com/GoogleChromeLabs/chrome-for-testing#json-api-endpoints json_str := urldownloadtovar("https://googlechromelabs.github.io/chrome-for-testing/known-good-versions-with-downloads.json") @@ -84,22 +105,25 @@ GetURLofLatestChromedriver(ChromeVersion){ VersionIndex := A_Index - ; loop through the platforms to get download URL + ; loop through the platforms to get download URL for Chrome + loop % parsed.versions[VersionIndex].downloads.chrome.count() { + + if(parsed.versions[VersionIndex].downloads.chrome[A_Index].platform = "win64") + chromeDLURL64 := parsed.versions[VersionIndex].downloads.chromedriver[A_Index].url + } + + + ; loop through the platforms to get download URL for Chromedriver loop % parsed.versions[VersionIndex].downloads.chromedriver.count() { - ; 64 bit version if(parsed.versions[VersionIndex].downloads.chromedriver[A_Index].platform = "win64") chromedriverDLURL64 := parsed.versions[VersionIndex].downloads.chromedriver[A_Index].url - - ; 32 bit version - if(parsed.versions[VersionIndex].downloads.chromedriver[A_Index].platform = "win32") - chromedriverDLURL32 := parsed.versions[VersionIndex].downloads.chromedriver[A_Index].url } + break } } - ; Msgbox % "chromedriverDLURL32: " chromedriverDLURL32 - ; Msgbox % "chromedriverDLURL64: " chromedriverDLURL64 - return chromedriverDLURL32 + URLS = %chromeDLURL64%||%chromedriverDLURL64% + return URLS } \ No newline at end of file