@ -2,6 +2,61 @@
;------------------------------------------------
;------------------------------------------------
GetChromeVersion(){
; https://stackoverflow.com/questions/52457766/how-can-i-get-google-chromes-version-number
; Command = powershell `$ChromePath = 'C:\Program Files\Google\Chrome\Application\chrome.exe' `; [System.Diagnostics.FileVersionInfo]::GetVersionInfo($ChromePath).ProductVersion
command = powershell $(Get-Package -Name 'Google Chrome').Version
ChromeVersion := RunCMD(command)
ChromeVersion := StrSplit(ChromeVersion, "`r")[1] ; remove newline character if it exists
return ChromeVersion
}
DownloadLatestChromeDriver(ChromeVersion){
json_str := urldownloadtovar("https://googlechromelabs.github.io/chrome-for-testing/known-good-versions-with-downloads.json")
; requires #include of json.ahk in parent script
parsed := JSON.Load(json_str)
ChromelabsJsonEntriesCount := parsed.versions.count()
if(ChromelabsJsonEntriesCount = ""){
return "Failed to parse chromedriver json. "
}
loop % ChromelabsJsonEntriesCount {
if(A_index = ChromelabsJsonEntriesCount){
Message = "Failed to find %ChromeVersion% in the ChromeLabs Json"
return Message
}
if(ChromeVersion = parsed.versions[A_Index].version){
VersionIndex := A_Index
; loop through the platforms to get download URL
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
}
ShowSeleniumErrorMsgbox(){
ShowSeleniumErrorMsgbox(){
GetChromeVersionCommand = powershell (Get-Item '%ChromeFilepath%').VersionInfo.ProductVersion
GetChromeVersionCommand = powershell (Get-Item '%ChromeFilepath%').VersionInfo.ProductVersion
@ -35,10 +90,6 @@ ShowSeleniumErrorMsgbox(){
}
}
/*
/*
*/
*/
@ -481,6 +532,8 @@ CheckURLForSubstring(Substring){
; End of Function
; End of Function
; -------------------------------/NavigateFromBaseURL-------------------------------
; -------------------------------/NavigateFromBaseURL-------------------------------
; -------------------------------SaveDriverURL-------------------------------
SaveDriverURL(){ ; save the url of the result page. That way if a tab is not found for a site, we can open up a tab from this tab instead of middle of nowhere. That way we can keep the tabs together
SaveDriverURL(){ ; save the url of the result page. That way if a tab is not found for a site, we can open up a tab from this tab instead of middle of nowhere. That way we can keep the tabs together
try LastWebsitePostURL := driver.URL
try LastWebsitePostURL := driver.URL
@ -561,37 +614,6 @@ SChrome_Get(URL := "", Profile := "Profile 1", IP_Port := "127.0.0.1:9222"){
*/
*/
; -------------------------------HasVal-------------------------------
; Function needed for finding a value in an array
HasVal(haystack, needle)
{
if !(IsObject(haystack)) || (haystack.Length() = 0)
return 0
for index, value in haystack
if (value = needle)
return index
return 0
}
; -------------------------------/HasVal-------------------------------
HasSubstringVal(haystack, needle)
{
if !(IsObject(haystack)) || (haystack.Length() = 0)
return 0
for index, value in haystack
if (InStr(value, Needle))
return index
return 0
}
; SubStr(String, StartingPos [, Length])
; InStr(value, Needle)
/*
*/
; Various functions used to control Selenium, Chrome and Chrome.AHK
; Various functions used to control Selenium, Chrome and Chrome.AHK
;---Javascript---
;---Javascript---
;------------------------------------------------
;------------------------------------------------
@ -823,6 +845,11 @@ Selenium_LoopToClearXpath(Xpath,NumOfLoops:=1,SleepLength:=1000){
}
}
}
}
SaveDriverURLOFErrorPage(){ ; save the url of the result page. That way if a tab is not found for a site, we can open up a tab from this tab instead of middle of nowhere. That way we can keep the tabs together
try URLOfLastErrorPage := driver.URL
}
;---\Selenium---
;---\Selenium---
;------------------------------------------------
;------------------------------------------------
@ -961,3 +988,5 @@ OnMsgBoxJSReturnData() {
ControlSetText Button3, Return
ControlSetText Button3, Return
}
}
}
}