Google Groups Home
Help | Sign in
How to detect if a dialog is present
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  12 messages - Collapse all
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
Xu, Qian  
View profile
 More options May 17, 10:20 am
Newsgroups: comp.lang.javascript
From: "Xu, Qian" <quian...@stud.tu-ilmenau.de>
Date: Sat, 17 May 2008 16:20:46 +0200
Local: Sat, May 17 2008 10:20 am
Subject: How to detect if a dialog is present
Hi All,

Is it possible to detect whether a (confirmation or prompt) dialog is
present? And furthermore, how to press OK, Cancel buttons of a dialog?

I am writing a javascript based test framework. I would like to detect
and close dialog using javascript.

Thanks in advance
--
   Xu, Qian (stanleyxu)
     http://stanleyxu2005.blogspot.com


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Thomas 'PointedEars' Lahn  
View profile
 More options May 17, 10:50 am
Newsgroups: comp.lang.javascript
From: Thomas 'PointedEars' Lahn <PointedE...@web.de>
Date: Sat, 17 May 2008 16:50:01 +0200
Local: Sat, May 17 2008 10:50 am
Subject: Re: How to detect if a dialog is present

Xu, Qian wrote:
> Is it possible to detect whether a (confirmation or prompt) dialog is
> present?

No, such dialogs are always modal.  Script execution in the window from
which these have been issued is halted until they have been closed.

> And furthermore, how to press OK, Cancel buttons of a dialog?

You can't.

PointedEars
--
    realism:    HTML 4.01 Strict
    evangelism: XHTML 1.0 Strict
    madness:    XHTML 1.1 as application/xhtml+xml
                                                    -- Bjoern Hoehrmann


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
VK  
View profile
(2 users)  More options May 17, 11:26 am
Newsgroups: comp.lang.javascript
From: VK <schools_r...@yahoo.com>
Date: Sat, 17 May 2008 08:26:44 -0700 (PDT)
Local: Sat, May 17 2008 11:26 am
Subject: Re: How to detect if a dialog is present
On May 17, 6:50 pm, Thomas 'PointedEars' Lahn <PointedE...@web.de>
wrote:

> Xu, Qian wrote:
> > Is it possible to detect whether a (confirmation or prompt) dialog is
> > present?

> No, such dialogs are always modal.  Script execution in the window from
> which these have been issued is halted until they have been closed.

A dangerous mistake I once had big troubles with. In Gecko-based
browsers including Firefox build-in dialogs are modal only withing the
current execution context. Because timed calls creating new contexts,
they are excluded from the lock. I have no idea why such "pseudo-
threading" was allowed for external scripts. Either indeed some
reasons for that or some initial bug which is too late to fix. No any
other known to me engine does that. For instance "enjoy" three alerts
displayed at once on Firefox:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html lang="en_US">
<head>
<meta http-equiv="Content-type"
 content="text/html; charset=iso-8859-1">
<title>Demo</title>
<style type="text/css">
* {
 box-sizing: border-box;
-moz-box-sizing: border-box;
-ms-box-sizing: border-box;

}

p {
 font: 1em Georgia, serif;
}

</style>
<script type="text/javascript">

var counter = 0;

function demo() {
 window.alert('Pseudo-thread #' + ++counter);

}

function init() {
 window.setTimeout('demo()',500);
 window.setTimeout('demo()',1000);
 window.setTimeout('demo()',1500);

}

window.onload = init;
</script>
</head>
<body>
<p>No content.</p>
</body>
</html>

> > And furthermore, how to press OK, Cancel buttons of a dialog?

> You can't.

That is correct.

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Lasse Reichstein Nielsen  
View profile
 More options May 17, 11:43 am
Newsgroups: comp.lang.javascript
From: Lasse Reichstein Nielsen <l...@hotpop.com>
Date: Sat, 17 May 2008 17:43:41 +0200
Local: Sat, May 17 2008 11:43 am
Subject: Re: How to detect if a dialog is present

"Xu, Qian" <quian...@stud.tu-ilmenau.de> writes:
> Is it possible to detect whether a (confirmation or prompt) dialog is
> present?

No. While the dialog is being presented, script execution on the page
is stopped. So, from another perspective, it is trivial. If your code
is running, no dialog is being shown.

> And furthermore, how to press OK, Cancel buttons of a dialog?

User interaction.

> I am writing a javascript based test framework. I would like to detect
> and close dialog using javascript.

The traditional way that test-frameworks do this is to overwrite the
alert and confirm functions with code that simulates a pressed button.
The code using them doesn't need to know, it just gets a preconfigured
answer back.

It might not match your requirements, but try looking at the Selenium
test framework.
 http://selenium-core.openqa.org/

/L
--
Lasse Reichstein Nielsen  -  l...@hotpop.com
 DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
  'Faith without judgement merely degrades the spirit divine.'


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Thomas 'PointedEars' Lahn  
View profile
 More options May 17, 11:51 am
Newsgroups: comp.lang.javascript
From: Thomas 'PointedEars' Lahn <PointedE...@web.de>
Date: Sat, 17 May 2008 17:51:44 +0200
Local: Sat, May 17 2008 11:51 am
Subject: Re: How to detect if a dialog is present

VK wrote:
> On May 17, 6:50 pm, Thomas 'PointedEars' Lahn <PointedE...@web.de> wrote:
>> Xu, Qian wrote:
>>> Is it possible to detect whether a (confirmation or prompt) dialog is
>>>  present?
>> No, such dialogs are always modal.  Script execution in the window from
>> which these have been issued is halted until they have been closed.

> A dangerous mistake

My wording was just imprecise.

> I once had big troubles with.

No offense meant, but given the nature and number of misconceptions you have
demonstrated before, one wonders how you are able to write working code at all.

> In Gecko-based browsers including Firefox build-in dialogs are modal only
> withing the current execution context.

I was aware of that.

> [example code]

Your examples could be much shorter if you omitted all the unnecessary parts.

PointedEars
--
Use any version of Microsoft Frontpage to create your site.
(This won't prevent people from viewing your source, but no one
will want to steal it.)
  -- from <http://www.vortex-webdesign.com/help/hidesource.htm>


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
SAM  
View profile
 More options May 17, 2:50 pm
Newsgroups: comp.lang.javascript
From: SAM <stephanemoriaux.NoAd...@wanadoo.fr.invalid>
Date: Sat, 17 May 2008 20:50:02 +0200
Local: Sat, May 17 2008 2:50 pm
Subject: Re: How to detect if a dialog is present
VK a écrit :

> For instance "enjoy" three alerts
> displayed at once on Firefox:

I've seen 3 successive alerts ... not at once :-)

> * {
>  box-sizing: border-box;
> -moz-box-sizing: border-box;
> -ms-box-sizing: border-box;
> }

what these styles are supposed to do ?

--
sm


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
VK  
View profile
(2 users)  More options May 17, 2:59 pm
Newsgroups: comp.lang.javascript
From: VK <schools_r...@yahoo.com>
Date: Sat, 17 May 2008 11:59:12 -0700 (PDT)
Local: Sat, May 17 2008 2:59 pm
Subject: Re: How to detect if a dialog is present

> > For instance "enjoy" three alerts
> > displayed at once on Firefox:

> I've seen 3 successive alerts ... not at once :-)

I mean if you don't close each alert right away then in ~1.5sec you'll
have three alerts at once on the screen: drag one to see other
underneath etc. You may arrange them nicely on the screen, make a
screen shot of it and send to Mozilla like "Who may guess what a hey
is that?" :-) Maybe someone knows it. :-)

> > * {
> >  box-sizing: border-box;
> > -moz-box-sizing: border-box;
> > -ms-box-sizing: border-box;
> > }

> what these styles are supposed to do ?

Nothing relevant to the script. I just grabbed the first template from
the list to make the demo. Normally we are using it in combination
with HTML Transitional doctype to have the normal box model for all
supported browsers (IE6/IE7, Firefox etc.) See if interested
http://www.quirksmode.org/css/box.html

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
SAM  
View profile
 More options May 17, 10:09 pm
Newsgroups: comp.lang.javascript
From: SAM <stephanemoriaux.NoAd...@wanadoo.fr.invalid>
Date: Sun, 18 May 2008 04:09:51 +0200
Local: Sat, May 17 2008 10:09 pm
Subject: Re: How to detect if a dialog is present
VK a écrit :

>>> For instance "enjoy" three alerts
>>> displayed at once on Firefox:
>> I've seen 3 successive alerts ... not at once :-)

> I mean if you don't close each alert right away then in ~1.5sec you'll
> have three alerts at once on the screen: drag one to see other
> underneath etc.

No, I'm sorry but I haven't that (on my Mac) with Firefox.
The box(es) is(are) centered and attached at the window title bar.
With my old IE, Opera and Safari, dialog boxes are floating and ... no
... only one alert after the other.

>>> * {
>>>  box-sizing: border-box;
>>> -moz-box-sizing: border-box;
>>> -ms-box-sizing: border-box;
>>> }
>> what these styles are supposed to do ?

> Nothing relevant to the script.

Ha!? OK

> Normally we are using it in combination
> with HTML Transitional doctype to have the normal box model for all
> supported browsers (IE6/IE7, Firefox etc.) See if interested
> http://www.quirksmode.org/css/box.html

That force IE to see borders as all other browsers ?

--
sm


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
VK  
View profile
(2 users)  More options May 18, 6:28 am
Newsgroups: comp.lang.javascript
From: VK <schools_r...@yahoo.com>
Date: Sun, 18 May 2008 03:28:38 -0700 (PDT)
Local: Sun, May 18 2008 6:28 am
Subject: Re: How to detect if a dialog is present
On May 18, 6:09 am, SAM <stephanemoriaux.NoAd...@wanadoo.fr.invalid>
wrote:

> VK a écrit :

> >>> For instance "enjoy" three alerts
> >>> displayed at once on Firefox:
> >> I've seen 3 successive alerts ... not at once :-)

> > I mean if you don't close each alert right away then in ~1.5sec you'll
> > have three alerts at once on the screen: drag one to see other
> > underneath etc.

> No, I'm sorry but I haven't that (on my Mac) with Firefox.
> The box(es) is(are) centered and attached at the window title bar.
> With my old IE, Opera and Safari, dialog boxes are floating and ... no
> ... only one alert after the other.

Strange. Is Firefox using a different script engine for MacOS? I'm
going to check. For Windows and for Linux it is the same as I
described. Here for instance Firefox under Mandriva Linux 2008.1
Spring:
http://www.geocities.com/schools_ring/tmp/alert.png

It forces others plus IE to calculate the container size properly
instead of W3C's "content only" schema. On big projects it saves an
ocean of time and efforts. From the other side I already explained
that I just grabbed the first template I had to make the demo. I
didn't want nor willing to start rwars over box models. I personally
do agree with Peter-Paul Koch and I do consider W3C's box model -
after being tried many times - as hugely inconvenient for any
practical use. Yet I am not pushing my opinion onto community - and
definitely not at c.l.j.

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
SAM  
View profile
 More options May 18, 7:06 pm
Newsgroups: comp.lang.javascript
From: SAM <stephanemoriaux.NoAd...@wanadoo.fr.invalid>
Date: Mon, 19 May 2008 01:06:11 +0200
Local: Sun, May 18 2008 7:06 pm
Subject: Re: How to detect if a dialog is present
VK a écrit :

I've always seen JS alert stopping function(s).
Since NC3, at least on Mac.
While a modal box is opened nothing in JS client side can happen.
I think that if a setTimeout was launched before the alert, the time of
wait continues to be counted whereas the box is opened.
With your example if we close a box the following one opens at once.
( The waiting time is finished)

> Here for instance Firefox under Mandriva Linux 2008.1
> Spring:
> http://www.geocities.com/schools_ring/tmp/alert.png

Firefox 2 on Mac OS X 10.4.10 :
<http://cjoint.com/?ftaTIkBLqi>

--
sm


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Xu, Qian  
View profile
 More options May 19, 10:06 pm
Newsgroups: comp.lang.javascript
From: "Xu, Qian" <quian...@stud.tu-ilmenau.de>
Date: Tue, 20 May 2008 04:06:37 +0200
Local: Mon, May 19 2008 10:06 pm
Subject: Re: How to detect if a dialog is present

Lasse Reichstein Nielsen wrote:

> The traditional way that test-frameworks do this is to overwrite the
> alert and confirm functions with code that simulates a pressed button.
> The code using them doesn't need to know, it just gets a preconfigured
> answer back.

> It might not match your requirements, but try looking at the Selenium
> test framework.
>  http://selenium-core.openqa.org/

> /L

Sounds smart ;) Thank you All

--
   Xu, Qian (stanleyxu)
     http://stanleyxu2005.blogspot.com


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.