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
js_SendAndCheckWithClassName(ClassName:="",ClassIndexNum:=0,ValueToCheck:="textContent",SleepLength:=1000,JSStringText:="TEXT"){
jsSend = document.getElementsByClassName('%ClassName%')[%ClassIndexNum%].value = "%JSStringText%";
@ -145,8 +164,8 @@ Selenium_LoopToSendValueByName(ElementName,NumOfLoops:=1,SleepLength:=1000,Strin
Selenium_LoopToSendValueToXpath(Xpath,NumOfLoops:=1,SleepLength:=1000,StringTextContent:=""){
loop, %NumOfLoops% {
; ToolTip, Loop attempt: %A_index%
try driver.FindElementByXPath(Xpath).sendKeys(StringTextContent) ; Click on "upload image" button
catch e {
try driver.FindElementByXPath(Xpath).sendKeys(StringTextContent) ; Click on "upload image" button
catch e {
if(A_index = NumOfLoops){
Return "Failed"
}
@ -217,128 +236,128 @@ Selenium_LoopToClearXpath(Xpath,NumOfLoops:=1,SleepLength:=1000){
; -------------------------------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
}
; msgbox, here goes
; https://www.w3schools.com/jsref/dom_obj_all.asp
; -----TEXT CONTENT-----
js = return %jsref%.textContent;
try status := driver.executeScript(js)
; -----VALUE-----
js = return %jsref%.value;
try status := driver.executeScript(js)
OnMessage(0x44, "OnMsgBoxJSReturnData")
MsgBox 0x3,.TextContent:,%status%
OnMessage(0x44, "")
IfMsgBox Yes,{
OnMessage(0x44, "OnMsgBoxJSReturnData")
MsgBox 0x3,.value:,%status%
OnMessage(0x44, "")
} Else IfMsgBox No, {
TextForClip = js = %js% `n try, status := driver.executeScript(js)
Clipboard := TextForClip
} Else IfMsgBox Cancel, {
return
}
IfMsgBox Yes,{
; -----VALUE-----
js = return %jsref%.value;
try status := driver.executeScript(js)
} 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,.value:,%status%
OnMessage(0x44, "")
IfMsgBox Yes,{
OnMessage(0x44, "OnMsgBoxJSReturnData")
MsgBox 0x3, .innerText,%status%
OnMessage(0x44, "")
} Else IfMsgBox No, {
TextForClip = js = %js% `n try, status := driver.executeScript(js)
Clipboard := TextForClip
} Else IfMsgBox Cancel, {
return
}
IfMsgBox Yes,{
; -----INNERTEXT-----
js = return %jsref%.innerText;
try status := driver.executeScript(js)
} Else IfMsgBox No, {
TextForClip = js = %js% `n try, status := driver.executeScript(js)
Clipboard := TextForClip
} Else IfMsgBox Cancel, {
return
}
OnMessage(0x44, "OnMsgBoxJSReturnData")
MsgBox 0x3, .innerText,%status%
OnMessage(0x44, "")
; -----OuterText-----
js = return %jsref%.outerText;
try status := driver.executeScript(js)
IfMsgBox Yes,{
} Else IfMsgBox No, {
TextForClip = js = %js% `n try, status := driver.executeScript(js)
Clipboard := TextForClip
} Else IfMsgBox Cancel, {
return
}
OnMessage(0x44, "OnMsgBoxJSReturnData")
MsgBox 0x3, .outerText,%status%
OnMessage(0x44, "")
IfMsgBox Yes,{
; -----OuterText-----
js = return %jsref%.outerText;
try status := driver.executeScript(js)
} Else IfMsgBox No, {
TextForClip = js = %js% `n try, status := driver.executeScript(js)
Clipboard := TextForClip
} Else IfMsgBox Cancel, {
return
}
OnMessage(0x44, "OnMsgBoxJSReturnData")
MsgBox 0x3, .outerText,%status%
OnMessage(0x44, "")
;-----innerHTML-----
js = return %jsref%.innerHTML;
try status := driver.executeScript(js)
IfMsgBox Yes,{
} Else IfMsgBox No, {
TextForClip = js = %js% `n try, status := driver.executeScript(js)
Clipboard := TextForClip
} Else IfMsgBox Cancel, {
return
}
OnMessage(0x44, "OnMsgBoxJSReturnData")
MsgBox 0x3, .innerHTML,%status%
OnMessage(0x44, "")
IfMsgBox Yes,{
;-----innerHTML-----
js = return %jsref%.innerHTML;
try status := driver.executeScript(js)
} Else IfMsgBox No, {
TextForClip = js = %js% `n try, status := driver.executeScript(js)
Clipboard := TextForClip
} Else IfMsgBox Cancel, {
return
}
OnMessage(0x44, "OnMsgBoxJSReturnData")
MsgBox 0x3, .innerHTML,%status%
OnMessage(0x44, "")
; -----outerHTML-----
js = return %jsref%.outerHTML;
try status := driver.executeScript(js)
IfMsgBox Yes,{
} Else IfMsgBox No, {
TextForClip = js = %js% `n try, status := driver.executeScript(js)
Clipboard := TextForClip
} Else IfMsgBox Cancel, {
return
}
OnMessage(0x44, "OnMsgBoxJSReturnData")
MsgBox 0x3, .outerHTML,%status%
OnMessage(0x44, "")
IfMsgBox Yes,{
; -----outerHTML-----
js = return %jsref%.outerHTML;
try status := driver.executeScript(js)
} Else IfMsgBox No, {
TextForClip =js = %js% `n try,status := driver.executeScript(js)
Clipboard := TextForClip
} Else IfMsgBox Cancel, {
return
}
OnMessage(0x44, "OnMsgBoxJSReturnData")
MsgBox 0x3, .outerHTML,%status%
OnMessage(0x44, "")
} ; end of fuctions
IfMsgBox Yes,{
} Else IfMsgBox No, {
TextForClip =js = %js% `n try,status := driver.executeScript(js)
Clipboard := TextForClip
} Else IfMsgBox Cancel, {
return
}
OnMsgBoxJSReturnData() {
DetectHiddenWindows, On
Process, Exist
If (WinExist("ahk_class #32770 ahk_pid " . ErrorLevel)) {
ControlSetText Button1, OK
ControlSetText Button2, Copy
ControlSetText Button3, 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
}
}

Loading…
Cancel
Save