From 409e93e7d13796f4b894ea8c7ef8385aef0ba3a4 Mon Sep 17 00:00:00 2001 From: yuriy Date: Wed, 15 Feb 2023 23:36:01 -0500 Subject: [PATCH] Added function for checking javascript element values --- Lib/ChromeAutomationFunctions.ahk | 128 ++++++++++++++++++++++++++++++ 1 file changed, 128 insertions(+) diff --git a/Lib/ChromeAutomationFunctions.ahk b/Lib/ChromeAutomationFunctions.ahk index 07fc606..5edf137 100644 --- a/Lib/ChromeAutomationFunctions.ahk +++ b/Lib/ChromeAutomationFunctions.ahk @@ -214,3 +214,131 @@ Selenium_LoopToClearXpath(Xpath,NumOfLoops:=1,SleepLength:=1000){ ;---\Selenium--- ;------------------------------------------------ + +; -------------------------------Javascript------------------------------- +ReturnAndDisplayJSData(jsref){ +; msgbox, here goes +; https://www.w3schools.com/jsref/dom_obj_all.asp +; -----TEXT CONTENT----- +js = return %jsref%.textContent; +try status := driver.executeScript(js) + +OnMessage(0x44, "OnMsgBoxJSReturnData") +MsgBox 0x3,.TextContent:,%status% +OnMessage(0x44, "") + +IfMsgBox Yes,{ + +} Else IfMsgBox No, { +TextForClip = js = %js% `n try, status := driver.executeScript(js) +Clipboard := TextForClip +} Else IfMsgBox Cancel, { +return +} + +; -----VALUE----- +js = return %jsref%.value; +try status := driver.executeScript(js) + + +OnMessage(0x44, "OnMsgBoxJSReturnData") +MsgBox 0x3,.value:,%status% +OnMessage(0x44, "") + +IfMsgBox Yes,{ + +} Else IfMsgBox No, { +TextForClip = js = %js% `n try, status := driver.executeScript(js) +Clipboard := TextForClip +} Else IfMsgBox Cancel, { +return +} + +; -----INNERTEXT----- +js = return %jsref%.innerText; +try status := driver.executeScript(js) + + +OnMessage(0x44, "OnMsgBoxJSReturnData") +MsgBox 0x3, .innerText,%status% +OnMessage(0x44, "") + +IfMsgBox Yes,{ + +} Else IfMsgBox No, { +TextForClip = js = %js% `n try, status := driver.executeScript(js) +Clipboard := TextForClip +} Else IfMsgBox Cancel, { +return +} + + +; -----OuterText----- +js = return %jsref%.outerText; +try status := driver.executeScript(js) + + +OnMessage(0x44, "OnMsgBoxJSReturnData") +MsgBox 0x3, .outerText,%status% +OnMessage(0x44, "") + +IfMsgBox Yes,{ + +} Else IfMsgBox No, { +TextForClip = js = %js% `n try, status := driver.executeScript(js) +Clipboard := TextForClip +} Else IfMsgBox Cancel, { +return +} + + +;-----innerHTML----- +js = return %jsref%.innerHTML; +try status := driver.executeScript(js) + + +OnMessage(0x44, "OnMsgBoxJSReturnData") +MsgBox 0x3, .innerHTML,%status% +OnMessage(0x44, "") + +IfMsgBox Yes,{ + +} Else IfMsgBox No, { +TextForClip = js = %js% `n try, status := driver.executeScript(js) +Clipboard := TextForClip +} Else IfMsgBox Cancel, { +return +} + + +; -----outerHTML----- +js = return %jsref%.outerHTML; +try status := driver.executeScript(js) + + +OnMessage(0x44, "OnMsgBoxJSReturnData") +MsgBox 0x3, .outerHTML,%status% +OnMessage(0x44, "") + +IfMsgBox Yes,{ + +} Else IfMsgBox No, { +TextForClip =js = %js% `n try,status := driver.executeScript(js) +Clipboard := TextForClip +} Else IfMsgBox Cancel, { +return +} + + +} ; end of fuctions + + +OnMsgBoxJSReturnData() { + DetectHiddenWindows, On + Process, Exist + If (WinExist("ahk_class #32770 ahk_pid " . ErrorLevel)) { + ControlSetText Button1, OK + ControlSetText Button2, Copy + ControlSetText Button3, Return + } +}