Silent SHDocVw.InternetExplorer
I have a service that uses an invisible web browser to simulate users visiting websites, clicking links, filling in data and submitting buttons. It somehow works.
The problem is that this needs to be completely automatic, there's noone who'd click off the JavaScript alerts, popups and other trash. You might think that there's an option to the InternetExplorer object you could set to prevent them, but ... well if there is I did not find it.
I can prevent the popups from within the NewWindow2 event, but the only way I found to prevent alert()s, confirm()s and other JavaScript functions from ruinging everything is to overwrite their implementation by inserting something like
<script>
function window.alert(msg) {...}
...
</script>
into the page in the DocumentComplete even handler. This works fine for the alerts called from onClick and other JavaScript handlers, it's even soon enough for those called from <body onLoad="HERE">, but if the page contains
<script>
alert("Gotcha!");
</script>
the message gets displayed before the DocumentComplete event triggers and the program times out waiting for page completion. And even worse the browser then refuses to quit. Which means that the program starts to accumulate browsers waiting for the nonexistant user to click the invisibe messagebox. And that the per-session cookies are not forgotten after each task, which causes the sites to think I'm already logged in and the scripts fail.
So does anyone have any idea how to prevent that (censored) invisible messagebox?
Thanks a lot, Jenda
P.S.: The sites do know we are doing this to them!
|