Click() is clicking twice in Selenium 2.3.0 and 2.4.0

3,468 views
Skip to first unread message

Vincent Massol

unread,
Aug 18, 2011, 2:17:01 PM8/18/11
to webd...@googlegroups.com
Hi guys,

I've the following code:

WebElement element = getDriver().findElement(
            By.xpath("//div[@id='_attachments']//a[contains(@href, '" + attachmentName + "')]"));
element.click();

When this code is executed I can see on the request log of my server that 2 calls are made:

0:0:0:0:0:0:0:1%0 -  -  [18/Aug/2011:18:06:40 +0000] "GET /xwiki/bin/download/AttachmentTest/testUploadDownloadTwoAttachments/SmallAttachment.txt HTTP/1.1" 200 28 
0:0:0:0:0:0:0:1%0 -  -  [18/Aug/2011:18:06:40 +0000] "GET /xwiki/bin/download/AttachmentTest/testUploadDownloadTwoAttachments/SmallAttachment.txt HTTP/1.1" 200 28 

If I execute the same thing manually, only 1 such request is made.

Any idea what could be wrong?

Note that I have a custom WebDriver impl but it's only wrapping the original driver, see

I'm using it like this:
        this.driver = new XWikiWrappingDriver(new FirefoxDriver(), getUtil());

Thanks

Kristian Rosenvold

unread,
Aug 18, 2011, 2:24:20 PM8/18/11
to webd...@googlegroups.com
I've seen this happen when you have multiple elements in the DOM that match; some months/versions ago to be fair.

Kristian
--
You received this message because you are subscribed to the Google Groups "webdriver" group.
To view this discussion on the web visit https://groups.google.com/d/msg/webdriver/-/iwcYBrRWxxcJ.
To post to this group, send email to webd...@googlegroups.com.
To unsubscribe from this group, send email to webdriver+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/webdriver?hl=en.

Vincent Massol

unread,
Aug 18, 2011, 3:27:08 PM8/18/11
to webd...@googlegroups.com
Thanks Kristian.

However I've checked and there's only a single element matching the xpath expression I have (I called findElements() before and called size() on it and verified it returns 1).

Any other thing I could check?

Thanks
-Vincent

Robert Rollins

unread,
Aug 18, 2011, 5:46:46 PM8/18/11
to webdriver
I'm seeing this exact same thing, in Python. I've boiled away all the
potential issues in my own code, and confirmed without a doubt that
this line of code clicks the link it finds twice:

driver.find_element_by_link_text("Create next catalog
edition").click()

There's no other elements on the page with that link text. Clicking
the link manually works as expected. I've tested it with other links
on the same page, and the same thing happens. However, this double
clicking behavior doesn't appear to occur on form submit buttons.
Just links.

I've tried this with Selenium 2.4.0, 2.3.0, 2.2.0, and 2.1.0, using
pip, and this happens in every version.

I'm on a Mac (OSX 10.6), so I only have two supported browser choices:
Firefox and Chrome. Fortunately, this double-clicking only occurs in
Firefox. I've drilled down through the client-side webdriver code,
and nothing appears to be wrong... so I believe this bug is located
inside the webdriver.xpi firefox extension that the code installs when
it launches the Firefox instance.

Robert Rollins

unread,
Aug 19, 2011, 1:11:43 PM8/19/11
to webdriver
After diging around in the webdriver firefox extension code, I think I
found the bug. On line 6777 of the file webdriver.xpi/resource/
modules/atoms.js:
a.target ? c.open(b, a.target) : c.location.href = b

the "c.location.href = b" assignment is causing the browser to
navigate to the specified link a second time. The first time occurs
in webdriver.xpi/components/wrappedElement.js, on line 137:
res = this.mouse.click(wrapped);


I'm a total novice at Firefox Extension programming, so I haven't got
the faintest clue which of these is "wrong." But by editing the line
in atoms.js to not do that location assignment, the second click stops
happening, and it doesn't appear to mess up other clicks (like form
buttons).

Daniel Wagner-Hall

unread,
Aug 19, 2011, 2:23:17 PM8/19/11
to webd...@googlegroups.com
What version of firefox are you using? As I remember it, this is
version-specific code. Do you have a reduced test case we can use to
reproduce the issue?

> --
> You received this message because you are subscribed to the Google Groups "webdriver" group.

Robert Rollins

unread,
Aug 19, 2011, 4:56:09 PM8/19/11
to webdriver
Ahhh, I didn't realize that the code was version-specific. I was
using Firefox 3.6; telling WebDriver to use my copy of Firefox 6.0
made the double clicking go away.

As for a reproducible test case (in Python):

from selenium.webdriver import Firefox
driver = Firefox()
driver.get('http://www.google.com')
driver.find_element_by_link_text('Business Solutions').click()


It will be difficult to notice the double-click bug manifesting here,
since it only occurs on href links, and those tend not to have a
visual difference between one and two clicks (I couldn't find a public
website that would make it easy to confirm the bug). But I can
confirm this test will reproduce the href double-click bug in Firefox
3.6, but not in Firefox 6. I've been seeing the problem on my own
private web app, and my logs show me that it's clicking twice.

Vincent Massol

unread,
Aug 23, 2011, 5:25:43 AM8/23/11
to webd...@googlegroups.com
I've now opened an issue at http://code.google.com/p/selenium/issues/detail?id=2320

Thanks Robert for your digging. Let's hope the Selenium/Webdriver devs fix it soon. It's a real problem for us.

Dante

unread,
Aug 25, 2011, 5:27:17 PM8/25/11
to webd...@googlegroups.com
I noticed the same problem -- and I created a self-contained test to expose the bug.  I've attached it to the issue Vincent created.  

We noticed this after upgrading from 2.0b3 to 2.5.0 -- it turns out that the bug was introduced in 2.0.0 (the test passes using 2.0rc3).

--Dante

Daniel Wagner-Hall

unread,
Aug 26, 2011, 12:59:43 AM8/26/11
to webd...@googlegroups.com
Thanks for the report, and in particular the test case - I'm looking
in to this :)

> --
> You received this message because you are subscribed to the Google Groups
> "webdriver" group.

> To view this discussion on the web visit

> https://groups.google.com/d/msg/webdriver/-/GU6KK5uYFYwJ.

Chris Lamb

unread,
Dec 4, 2015, 7:45:55 AM12/4/15
to webdriver
Any update on this? I notice the issue is still present and is causing me headaches :(

Moises Siles

unread,
Dec 4, 2015, 1:56:06 PM12/4/15
to Webdriver
Could you try with the latest version of selenium webdriver?

To unsubscribe from this group and stop receiving emails from it, send an email to webdriver+...@googlegroups.com.

To post to this group, send email to webd...@googlegroups.com.

Chris Lamb

unread,
Dec 5, 2015, 8:47:30 AM12/5/15
to webd...@googlegroups.com
I've tried but it looks like this issue is specific to the IE driver. No such issues with Firefox (not yet tried chrome but will next week).

--
You received this message because you are subscribed to a topic in the Google Groups "webdriver" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/webdriver/tsuBgipwzRQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to webdriver+...@googlegroups.com.

Moises Siles

unread,
Dec 5, 2015, 9:44:00 AM12/5/15
to Webdriver
Could you confirm what version are you using webdriver and the IEdriver, also could you give more details about how to reproduce the issue? and could you share part of the html and code 

Regards
Reply all
Reply to author
Forward
0 new messages