From b5c3b4a606c7034aee3d511889fc0074dec1b890 Mon Sep 17 00:00:00 2001 From: Yuriy Date: Fri, 3 May 2024 12:52:49 -0400 Subject: [PATCH] error checkign and general msgbox window --- Selenium-Functions.ahk | 38 ++++++++++++++++++++++++-------------- 1 file changed, 24 insertions(+), 14 deletions(-) diff --git a/Selenium-Functions.ahk b/Selenium-Functions.ahk index 3ae63e9..7c09022 100644 --- a/Selenium-Functions.ahk +++ b/Selenium-Functions.ahk @@ -722,13 +722,13 @@ Selenium_LoopToSendValueByName(ElementName,NumOfLoops:=1,SleepLength:=1000,Strin Selenium_LoopToSendValueToXpath(Xpath,NumOfLoops:=1,SleepLength:=1000,StringTextContent:="",ClearElement:=0){ ; Msgbox % "StringTextContent: " StringTextContent -; Msgbox % "ClearElement: " ClearElement + ; Msgbox % "ClearElement: " ClearElement loop, %NumOfLoops% { ; msgbox % ClearElement if(ClearElement){ Loop, 3 { ; have to do it multiple times to make it trigger properly - driver.FindElementByXPath(Xpath).clear() + try, driver.FindElementByXPath(Xpath).clear() sleep, 500 } } @@ -834,26 +834,26 @@ SaveDriverURLOFErrorPage(){ ; save the url of the result page. That way if a tab GetHTMLValueFromXpathOuterHTML(XPATH, HTMLElementName){ -Try ElementOuterHTML := driver.findelementbyxpath(Xpath).Attribute("outerHTML") ;XPATH-ID & Tag -; try Clipboard := driver.findelementbyxpath(Xpath).Attribute("outerHTML") ;XPATH-ID & Tag -; Try MsgBox,,Element OuterHTML: `n, % driver.findelementbyxpath(Xpath).Attribute("outerHTML") ;XPATH-ID & Tag + Try ElementOuterHTML := driver.findelementbyxpath(Xpath).Attribute("outerHTML") ;XPATH-ID & Tag + ; try Clipboard := driver.findelementbyxpath(Xpath).Attribute("outerHTML") ;XPATH-ID & Tag + ; Try MsgBox,,Element OuterHTML: `n, % driver.findelementbyxpath(Xpath).Attribute("outerHTML") ;XPATH-ID & Tag -; Match string between quotes following the HTMLELEMENTNAME -RegexStatement = %HTMLElementName%="([^"]+)" + ; Match string between quotes following the HTMLELEMENTNAME + RegexStatement = %HTMLElementName%="([^"]+)" ; regexMatch := RegExMatch(ElementOuterHTML, "value=""([^""]+)""", match) regexMatch := RegExMatch(ElementOuterHTML, RegexStatement, match) if (regexMatch) { - ElementValue := match1 - ; Msgbox % "PostURL: " PostURL - ; Message = URL Pulled out from OuterHTML: %PostURL% - Return ElementValue + ElementValue := match1 + ; Msgbox % "PostURL: " PostURL + ; Message = URL Pulled out from OuterHTML: %PostURL% + Return ElementValue } else { - Message = Failed to Pull out value from OuterHTML - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") - Return "Failed" + Message = Failed to Pull out value from OuterHTML + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + Return "Failed" } } @@ -1004,3 +1004,13 @@ OnMsgBoxJSReturnData() { } + +; Show a user confirmation msgbox with a proceed and STOP buttons +; Used by the "Confirm before Submit" checkbox +OnMsgBoxUserConfirmation() { + DetectHiddenWindows, On + Process, Exist + If (WinExist("ahk_class #32770 ahk_pid " . ErrorLevel)) { + ControlSetText Button1, PROCEED + ControlSetText Button2, STOP + } \ No newline at end of file