views:

1271

answers:

4

Are there any plugins out there that will simulate a double click in any of the major browsers?

I'm trying to test some code that prevents double clicks on form submission buttons, and would love to be able to either use a hot key or the middle mouse button to send a double click to the browser.

Thanks Don

A: 

what i would do is this:

<input id="btn" type="submit" onclick="disableDblClick('btn')"/>

<script type="text/javascript">
function disableDblClick(obj)
{
    document.getElementById(obj).disabled = true;
    setTimeout("document.getElementById('btn').disabled = false", 100);
}

what this does is disable the button for 100 milliseconds. i didnt test this, but it should work, and it will be cross browser. and change the amount of time appropriately.

Samuel
My question wasn't how to prevent double clicks, it was how to automate the manual testing of double clicks. I have prevention code on the server that is pretty fool proof (using in memory session variables with token values), but I need to be able to test it out.
Don Cote
A: 

Is this for manual testing? If so, you could use a Microsoft Mouse and IntelliPoint. This would let you configure the mouse wheel click to be double click. I'm sure there are other mouse vendors who do similar things.

Martin Peck
Yeah - manual testing. I have a generic optical mouse with no special software. I wonder if I can intercept the click event in JavaScript and send through a double click instead.
Don Cote
You might find that the cost of the cheapest Microsoft mouse with IntelliPoint is less than the "cost" of doing it yourself. Plus, it'll work in more situations.
Martin Peck
Alternatively, go here...http://www.microsoft.com/hardware/download/download.aspx?category=MK... download IntelliPoint for a Basic Optical Mouse and see if you can configure your left click button to do double click.
Martin Peck
(or configure right click more likely)
Martin Peck
A: 

Observation: You're not really testing double-clicks. You're testing "more than one click". You'd still want the form submission button to be disabled even if the temporal distance between the two clicks was 5 seconds, wouldn't you?

So I think you've solved your own problem: just click twice!

sassafrass
Some of my forms are in modal dialog windows which are closed by the click event handler, so unfortunately they close before I can click more than once.
Don Cote
+1  A: 

I haven't used it myself, but I've heard good things about Selenium, a set of tools for testing websites. I imagine you can script a test that clicks twice with no delay.

Samir Talwar
This blog post is from a while ago, but the author extended the Selenium API to add a double click command:http://agiletesting.blogspot.com/2006/01/testing-commentary-and-thus-ajax-with.html
Don Cote