imacleod Posted December 16, 2015 Share Posted December 16, 2015 (edited) An IE page I'm interacting with has some JavaScript validation that pops if it doesn't like what it sees, e.g.:if (coname.value=='') { alert("Select a company for this action"); return false; }That freezes the script, so I've been trying to test for the existence of the alert window in my code by using WinExist, using the title text (default and explicit modes), and had no joy, it wasn't being detected, even though the title was valid according to the info tool. I read some other posts on here and tried using its class, and that has the opposite effect, it's true even when the dialogue is not there!Can anyone point out what I'm doing wrong here?if WinExists("[CLASS:#32770]") Then Send("{ENTER}") ConsoleWrite('@@ Debug:' & @ScriptLineNumber & @CRLF ) ;"Message from webpage", field validation error ;log the ID as having issues FileWriteLine($sLogFileName, _NowTime() & " " field validation error screen.") ;Open a new 'LIST page" _IENavigate($oIE, "http://*****") ExitLoop EndIfI'm puzzled by the binary WinExists behaviour for the alert dialog: false when I use its title, even if the alert has popped; true when using CLASS, regardless of whether the alert is present.I'll continue trawling through the other posts, but if anyone can point me in the right direction... Edited December 17, 2015 by imacleod Link to comment Share on other sites More sharing options...
imacleod Posted December 28, 2015 Author Share Posted December 28, 2015 No words of wisdom on offer? Link to comment Share on other sites More sharing options...
mikell Posted December 28, 2015 Share Posted December 28, 2015 This test script works for me#include <IE.au3> #include <MsgBoxConstants.au3> Adlibregister("test", 300) ; launches a sample page with an alert inside : ;<script> ; alert("Select a company for this action"); ;</script> Local $oIE = _IECreate("file:///" & @desktopdir & "\test.htm") Func test() Local $w = WinList("[CLASS:#32770]") For $i = 1 to $w[0][0] $t = WinGetText($w[$i][1]) If StringInStr($t, "company") Then Msgbox($MB_TOPMOST,"", "found it") Next EndFunc Link to comment Share on other sites More sharing options...
imacleod Posted January 1, 2016 Author Share Posted January 1, 2016 (edited) Cheers, I'll have a proper look at that next week when I'm back in the office. Edited January 8, 2016 by imacleod revert Link to comment Share on other sites More sharing options...
imacleod Posted January 8, 2016 Author Share Posted January 8, 2016 That didn't work for me, the ie_create errors. Not that I want to seem ungrateful, but can I circle back to the question of why WinExists always returns false when I use the window title, even if/when the alert has popped (I've confirmed the window title using the Info tool) and always returns true when I use the CLASS option (again, confirmed using the window title using the Info tool), regardless of whether the alert is present.Is that normal? It's beyond my understanding if it is.Feel free to tell me if I'm asking a stupid question... Link to comment Share on other sites More sharing options...
mikell Posted January 8, 2016 Share Posted January 8, 2016 This code should show why using only the class option is not reliable#include <Array.au3> $aWinList = WinList("[CLASS:#32770]") _ArrayDisplay($aWinList) imacleod 1 Link to comment Share on other sites More sharing options...
jguinch Posted January 8, 2016 Share Posted January 8, 2016 Mikell's code works for me with IE11.Also this one works :Func test() If WinExists("[CLASS:#32770]", "company") Then ControlClick( "[CLASS:#32770]", "Select a company for this action", "OK") EndIf EndFunc Spoiler Network configuration UDF, _DirGetSizeByExtension, _UninstallList Firefox ConfigurationArray multi-dimensions, Printer Management UDF Link to comment Share on other sites More sharing options...
imacleod Posted January 12, 2016 Author Share Posted January 12, 2016 Cheers guys. Mikell,So that illustrates that the class is not unique to the error message I'm trying to trap.Unfortunately I've missed my window of opportunity to test this easily; I'm going to have to request some dummy IDs that I can test with. I guess WinExists failing to trap by title must be a timing issue. I have a WinWaitNotActive immediately proceeding the WinExists, the error message is popped by javascript on the next page, a page that loads over a link that has ~120ms RTT, is that likely to need a sleep to allow the error to pop? If so, is there a better way of trapping the occasional error state, other than sleeping? I have ~3000 records to process and the WAN delay already means a run through takes a long time... Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now