bypass javascript alert

471 views
Skip to first unread message

cjokomay

unread,
Sep 9, 2008, 6:34:19 PM9/9/08
to Watir General
the apps that i am testing have an extremely basic javascript alert
that runs when the page loads. it is simply a message with an "ok"
button. i was wondering if there is any way possible to bypass this.

here is an example of the code:

<html>
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
</head>
<body onload="cpiBanner()">
<script language="javascript">
function cpiBanner() {
alert("NOTICE - PROPRIETARY SYSTEM\nThis system is intended to
be used solely by authorized users in the course of legitimate
corporate business.");
}
</script>
</body>
</html>

i was thinking using something similar to www::mechanize's update_html
function (http://groups.google.com/group/watir-general/browse_thread/
thread/392d3d2fd5f91965), but i don't see how that would work in this
situation.

the reason i want to bypass this alert is because when i run multiple
tests concurrently, when each script tries to clear the pop up around
the same time they tend to trip over each other and cause failures,
which is what i was getting at in this thread,
http://groups.google.com/group/watir-general/browse_thread/thread/3d827e6e198c1d37.
so, i am now hoping there is a way that i can just bypass that alert
altogether.

Bill Agee

unread,
Sep 9, 2008, 6:51:27 PM9/9/08
to watir-...@googlegroups.com
Some people get around this by running a separate process (or thread) that does nothing but check for the popup, dismiss it (if seen), sleep, and repeat.
 
You can start the popup killer at the beginning of your test and only kill it just before exiting.  Check out some of the code here:
 
Reply all
Reply to author
Forward
0 new messages