473,324 Members | 2,535 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

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
Jun 27 '08 #1
10 5743
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
Jun 27 '08 #2
"Xu, Qian" <qu******@stud.tu-ilmenau.dewrites:
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 - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
Jun 27 '08 #3
VK wrote:
On May 17, 6:50 pm, Thomas 'PointedEars' Lahn <PointedE...@web.dewrote:
>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>
Jun 27 '08 #4
SAM
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
Jun 27 '08 #5
VK
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
Jun 27 '08 #6
SAM
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
Jun 27 '08 #7
VK
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
>* {
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 ?
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.
Jun 27 '08 #8
SAM
VK a écrit :
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'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
Jun 27 '08 #9
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
Jun 27 '08 #10
In comp.lang.javascript message <k5**********@hotpop.com>, Sat, 17 May
2008 17:43:41, Lasse Reichstein Nielsen <lr*@hotpop.composted:

-
>Lasse Reichstein Nielsen - lr*@hotpop.com
That address, although in your header, sig, and Web site, still does not
work :
>A message that you sent could not be delivered to one or more of its
recipients. This is a permanent error. The following address(es) failed:
lr*@hotpop.com
SMTP error from remote mail server after RCPT TO:<lr*@hotpop.com>:
host mx1.hotpop.com [38.113.3.62]: 550 <lr*@hotpop.com>:
Recipient address rejected: Account closed due to inactivity. No forwarding information is available.
--
(c) John Stockton, nr London UK. ?@merlyn.demon.co.uk BP7, Delphi 3 & 2006.
<URL:http://www.merlyn.demon.co.uk/TP/BP/Delphi/&c., FAQqy topics & links;
<URL:http://www.bancoems.com/CompLangPascalDelphiMisc-MiniFAQ.htmclpdmFAQ;
<URL:http://www.borland.com/newsgroups/guide.htmlnews:borland.* Guidelines
Jun 27 '08 #11

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Quinn | last post by:
When users clicked a unkown mime type link such as Zip on my website, a "Save/Open/Cancel" dialog box pops up. Is there a way to detect which button users clicked by using ASP? actually I only what...
23
by: David McCulloch | last post by:
QUESTION-1: How can I detect if Norton Internet Security is blocking pop-ups? QUESTION-2a: How could I know if a particular JavaScript function has been declared? QUESTION-2b: How could I...
3
by: andrew.neale | last post by:
Hello, I have a div that has an overflow set to auto. I would like to know if the scrollbars are visible in javascript. Any help is appreciated. Thanks
6
by: hb | last post by:
Hi, Would you please tell me how to detect if the client's browser is closed? I need such event to trigger a database modification. Thank you hb
10
by: Guadala Harry | last post by:
I have a modal dialog that currently does all of the following except item 4. 1. lets users select a graphic from a list of thumbnails (and when selected, displays the full-size image in a...
2
by: ljlevend | last post by:
I have a file path (i.e., String) property that uses a System.Windows.Forms.Design.FileNameEditor as its System.ComponentModel.Editor. This property is exposed by a PropertyGrid. What I need to...
1
by: Jeremy | last post by:
Hello, I'm thinking this may be an easy one but I am getting frustrated. How can I detect if a process is showing a modal dialog. Like "Are you sure you want to exit?", or an error message...
14
by: Simon Abolnar | last post by:
I would like to know how to open child form from dialog form. Thanks for help! Simon
2
by: =?Utf-8?B?TGVuaTIwMDA=?= | last post by:
Hi, I would like to write a c# application. to detect if a modal dialog opens on another application, (e.g. notepad.exe save changes dialog when you click exit ) and auto cancel it. How do I detect...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.