added function for sending data with js and double checking that it got input

pull/2/head
Yuriy 2 years ago
parent d11f9ef94c
commit ea4552dde8

@ -16,6 +16,25 @@ JS_TryToExecute(JsToExecute,NumberofAttempts := 1,SleepLength:=1000){
js_SendAndCheckWithQuerySelector(Selector,ValueToCheck:="value",SleepLength:=1000,JSStringText:="TEXT"){
js = document.querySelector("%Selector%").value = "%JSStringText%";
try driver.executeScript(js)
sleep, %SleepLength%
js = return document.querySelector("#title").value;
try, status := driver.executeScript(js)
; DevModeMsgBox(status)
if(Status = "")
return "Failed"
else,
return ""
}
; ValueToCheckOptions = innertext,textContent,InnerHTML,outerHTML,value,href,option value ; ValueToCheckOptions = innertext,textContent,InnerHTML,outerHTML,value,href,option value
js_SendAndCheckWithClassName(ClassName:="",ClassIndexNum:=0,ValueToCheck:="textContent",SleepLength:=1000,JSStringText:="TEXT"){ js_SendAndCheckWithClassName(ClassName:="",ClassIndexNum:=0,ValueToCheck:="textContent",SleepLength:=1000,JSStringText:="TEXT"){
jsSend = document.getElementsByClassName('%ClassName%')[%ClassIndexNum%].value = "%JSStringText%"; jsSend = document.getElementsByClassName('%ClassName%')[%ClassIndexNum%].value = "%JSStringText%";
@ -217,123 +236,123 @@ Selenium_LoopToClearXpath(Xpath,NumOfLoops:=1,SleepLength:=1000){
; -------------------------------Javascript------------------------------- ; -------------------------------Javascript-------------------------------
ReturnAndDisplayJSData(jsref){ ReturnAndDisplayJSData(jsref){
; msgbox, here goes ; msgbox, here goes
; https://www.w3schools.com/jsref/dom_obj_all.asp ; https://www.w3schools.com/jsref/dom_obj_all.asp
; -----TEXT CONTENT----- ; -----TEXT CONTENT-----
js = return %jsref%.textContent; js = return %jsref%.textContent;
try status := driver.executeScript(js) try status := driver.executeScript(js)
OnMessage(0x44, "OnMsgBoxJSReturnData") OnMessage(0x44, "OnMsgBoxJSReturnData")
MsgBox 0x3,.TextContent:,%status% MsgBox 0x3,.TextContent:,%status%
OnMessage(0x44, "") OnMessage(0x44, "")
IfMsgBox Yes,{ IfMsgBox Yes,{
} Else IfMsgBox No, { } Else IfMsgBox No, {
TextForClip = js = %js% `n try, status := driver.executeScript(js) TextForClip = js = %js% `n try, status := driver.executeScript(js)
Clipboard := TextForClip Clipboard := TextForClip
} Else IfMsgBox Cancel, { } Else IfMsgBox Cancel, {
return return
} }
; -----VALUE----- ; -----VALUE-----
js = return %jsref%.value; js = return %jsref%.value;
try status := driver.executeScript(js) try status := driver.executeScript(js)
OnMessage(0x44, "OnMsgBoxJSReturnData") OnMessage(0x44, "OnMsgBoxJSReturnData")
MsgBox 0x3,.value:,%status% MsgBox 0x3,.value:,%status%
OnMessage(0x44, "") OnMessage(0x44, "")
IfMsgBox Yes,{ IfMsgBox Yes,{
} Else IfMsgBox No, { } Else IfMsgBox No, {
TextForClip = js = %js% `n try, status := driver.executeScript(js) TextForClip = js = %js% `n try, status := driver.executeScript(js)
Clipboard := TextForClip Clipboard := TextForClip
} Else IfMsgBox Cancel, { } Else IfMsgBox Cancel, {
return return
} }
; -----INNERTEXT----- ; -----INNERTEXT-----
js = return %jsref%.innerText; js = return %jsref%.innerText;
try status := driver.executeScript(js) try status := driver.executeScript(js)
OnMessage(0x44, "OnMsgBoxJSReturnData") OnMessage(0x44, "OnMsgBoxJSReturnData")
MsgBox 0x3, .innerText,%status% MsgBox 0x3, .innerText,%status%
OnMessage(0x44, "") OnMessage(0x44, "")
IfMsgBox Yes,{ IfMsgBox Yes,{
} Else IfMsgBox No, { } Else IfMsgBox No, {
TextForClip = js = %js% `n try, status := driver.executeScript(js) TextForClip = js = %js% `n try, status := driver.executeScript(js)
Clipboard := TextForClip Clipboard := TextForClip
} Else IfMsgBox Cancel, { } Else IfMsgBox Cancel, {
return return
} }
; -----OuterText----- ; -----OuterText-----
js = return %jsref%.outerText; js = return %jsref%.outerText;
try status := driver.executeScript(js) try status := driver.executeScript(js)
OnMessage(0x44, "OnMsgBoxJSReturnData") OnMessage(0x44, "OnMsgBoxJSReturnData")
MsgBox 0x3, .outerText,%status% MsgBox 0x3, .outerText,%status%
OnMessage(0x44, "") OnMessage(0x44, "")
IfMsgBox Yes,{ IfMsgBox Yes,{
} Else IfMsgBox No, { } Else IfMsgBox No, {
TextForClip = js = %js% `n try, status := driver.executeScript(js) TextForClip = js = %js% `n try, status := driver.executeScript(js)
Clipboard := TextForClip Clipboard := TextForClip
} Else IfMsgBox Cancel, { } Else IfMsgBox Cancel, {
return return
} }
;-----innerHTML----- ;-----innerHTML-----
js = return %jsref%.innerHTML; js = return %jsref%.innerHTML;
try status := driver.executeScript(js) try status := driver.executeScript(js)
OnMessage(0x44, "OnMsgBoxJSReturnData") OnMessage(0x44, "OnMsgBoxJSReturnData")
MsgBox 0x3, .innerHTML,%status% MsgBox 0x3, .innerHTML,%status%
OnMessage(0x44, "") OnMessage(0x44, "")
IfMsgBox Yes,{ IfMsgBox Yes,{
} Else IfMsgBox No, { } Else IfMsgBox No, {
TextForClip = js = %js% `n try, status := driver.executeScript(js) TextForClip = js = %js% `n try, status := driver.executeScript(js)
Clipboard := TextForClip Clipboard := TextForClip
} Else IfMsgBox Cancel, { } Else IfMsgBox Cancel, {
return return
} }
; -----outerHTML----- ; -----outerHTML-----
js = return %jsref%.outerHTML; js = return %jsref%.outerHTML;
try status := driver.executeScript(js) try status := driver.executeScript(js)
OnMessage(0x44, "OnMsgBoxJSReturnData") OnMessage(0x44, "OnMsgBoxJSReturnData")
MsgBox 0x3, .outerHTML,%status% MsgBox 0x3, .outerHTML,%status%
OnMessage(0x44, "") OnMessage(0x44, "")
IfMsgBox Yes,{ IfMsgBox Yes,{
} Else IfMsgBox No, { } Else IfMsgBox No, {
TextForClip =js = %js% `n try,status := driver.executeScript(js) TextForClip =js = %js% `n try,status := driver.executeScript(js)
Clipboard := TextForClip Clipboard := TextForClip
} Else IfMsgBox Cancel, { } Else IfMsgBox Cancel, {
return return
} }
} ; end of fuctions } ; end of fuctions
OnMsgBoxJSReturnData() { OnMsgBoxJSReturnData() {
DetectHiddenWindows, On DetectHiddenWindows, On
Process, Exist Process, Exist
If (WinExist("ahk_class #32770 ahk_pid " . ErrorLevel)) { If (WinExist("ahk_class #32770 ahk_pid " . ErrorLevel)) {
@ -341,4 +360,4 @@ OnMsgBoxJSReturnData() {
ControlSetText Button2, Copy ControlSetText Button2, Copy
ControlSetText Button3, Return ControlSetText Button3, Return
} }
} }

Loading…
Cancel
Save