After executing a ClickTag, if the web page pops a Javascript alert window, it seems to halt script execution. I created a test web page to illustrate.
The web page is shown below. Just a form with a button that will submit the form after an alert button is pressed:
function bp(but)
{
alert("Button pressed!");
but.form.submit();
}
The Webrecorder script looks like this:
// Generated by MacroScript WebRecorder 2.5
// Recorded on Thursday, September 29, 2011, at 10:42 AM
IE_Navigate>%IE[0]%,http://www.onlc.com/scripts/test.asp,r
IE_Wait>%IE[0]%,r
Wait>delay
Let>FrameName={""}
Let>FormName={""}
Let>TagValue={"b1"}
IE_ClickTag>%IE[0]%,str:FrameName,str:FormName,INPUT,ID,str:TagValue,r
WaitWindowOpen>Message from webpage
SetFocus>Message from webpage
IE_Wait>%IE[0]%,r
Press>Enter
Wait>delay
IE_Refresh>%IE[0]%,r
IE_Wait>%IE[0]%,r
Label>end_script
It loads the test page, clicks the button, waits for the alert window and just keeps waiting. I think it may never actually come back from the ClickTag call because if I add a MessageModal right after the ClickTag the message doesn't show up until I manually click ok on the alert window.
I must be missing some obvious solution because this must be a fairly common situation, that is, clicking a submit tag causes some validation to occur that pops an alert window.
Is there some other approach that I should use than the ClickTag?
Thanks,
Jim Palic
Webrecorder/IEAuto ClickTag stopped by Javascript Alert
Moderators: Dorian (MJT support), JRL
I was trying to solve this issue by catching the Javascript Alert popup in the main script. Since I don't really care about the content of the alert popups and just want to clear them so that the main script can continue, it occurred to me that I could run a separate helper script that would look for the popups and close them.
I start up the helper script from the main script with RunProgram. The helper script looks for "Message from webpage" windows using WaitForWindow in a loop. When it sees one it uses CloseWindow to close it. And it uses ProcessExists to figure out when the main script is done so it doesn't run forever.
This approach does the job for me.
I start up the helper script from the main script with RunProgram. The helper script looks for "Message from webpage" windows using WaitForWindow in a loop. When it sees one it uses CloseWindow to close it. And it uses ProcessExists to figure out when the main script is done so it doesn't run forever.
This approach does the job for me.