SeleniumHQ / selenium-google-code-issue-archive

Archive, please see main selenium repo
https://github.com/seleniumhq/selenium
346 stars 194 forks source link

Double click is not working - IE, FF - Java implementation #1722

Closed lukeis closed 8 years ago

lukeis commented 8 years ago

Originally reported on Google Code with ID 1722

What steps will reproduce the problem?
1. new Actions(webDriver).doubleClick(webDriver.findElement(...)).build().perform();
has no effect
2. DoubleClick actions consists from 2 actions - moveToLocation 0 this is working correctly
because I can see applying hover styles over the element but mouse.doubleClick(location)
does not working

What is the expected output? What do you see instead?
DoubleClick should work :-)

What version of the product are you using? On what operating system?
Trunk version of the selenium - revision 12243
Firefox 4 and IE 8
Windows 7
Java client

Please provide any additional information below.

I did and workaround (custom DoubleClickAction):
if (...firefox...) {
    ((JavascriptExecutor) webDriver).executeScript("var evt = document.createEvent('MouseEvents');
evt.initMouseEvent('dblclick',true, true, window, 0, 0, 0, 0, 0, false, false, false,
false, 0,null); arguments[0].dispatchEvent(evt);", webElement);
} else if (...ie...) {
    ((JavascriptExecutor) webDriver).executeScript("arguments[0].fireEvent('ondblclick');",
webElement); 
}

this "implementation" is working for me.
(Whole file is located here: http://acris.googlecode.com/svn/sesam/branches/1.1.0/sesam-selenium-support/src/main/java/sk/seges/sesam/core/test/webdriver/action/DoubleClickAction.java)

Hopefully this helps to someone.

Reported by nejakyusername on 2011-05-27 11:21:16

lukeis commented 8 years ago
inspired by this answer: http://stackoverflow.com/questions/3982442/selenium-2-webdriver-how-to-double-click-a-table-row-which-opens-a-new-window

Reported by nejakyusername on 2011-05-27 11:26:19

lukeis commented 8 years ago

Reported by simon.m.stewart on 2011-05-31 14:40:18

lukeis commented 8 years ago
Still not working in RC2. Please fix it - doubleclick is one of the most frequent interactions.
Test code:

// String siteUrlDblClick = "http://www.mkyong.com/wp-content/uploads/jQuery/jQuery-bind-unbind-example.html";
driver.get(siteUrlDblClick);
WebElement mouseOverElement = driver.findElement(By.id("BoxId"));
Actions builder = new Actions(driver);
Action doubleClick = builder.doubleClick(mouseOverElement).build();
doubleClick.perform();

Error message:
Exception in thread "main" org.openqa.selenium.UnsupportedCommandException: Unrecognized
command: POST /session/3feacf77-1cb4-4c3e-9f1a-ff8b76624b93/doubleclick
System info: os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1', java.version:
'1.6.0_24'
Driver info: driver.version: RemoteWebDriver
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
    at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:131)
    at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:105)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:409)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:413)
    at org.openqa.selenium.remote.RemoteWebDriver$RemoteMouse.doubleClick(RemoteWebDriver.java:683)
    at org.openqa.selenium.interactions.DoubleClickAction.perform(DoubleClickAction.java:38)
    at org.openqa.selenium.interactions.CompositeAction.perform(CompositeAction.java:31)

Reported by rostislav.matl on 2011-06-14 09:24:32

lukeis commented 8 years ago
Just a quick update - I'm working now on fixing issues related to mouse movement outside
the DOM. Once that's done, I'll fix double-clicking.

Reported by eran.mes on 2011-06-15 11:00:34

lukeis commented 8 years ago
Double click now works with synthesized events on Firefox, but not yet using native.

Reported by simon.m.stewart on 2011-06-28 02:10:14

lukeis commented 8 years ago
I have put a posting here - http://technoblaster.wordpress.com/2011/07/08/selenium-webdriver-dblclick-on-gxt-grid/

Reported by paramag on 2011-07-08 08:45:22

lukeis commented 8 years ago
Issue 1537 has been merged into this issue.

Reported by james.h.evans.jr on 2011-07-11 10:31:32

lukeis commented 8 years ago
have just tested the example from comment #3 on version 2.2. - in MSIE it show single
click, in Firefox 3.6.15 the Exception:

Exception in thread "main" org.openqa.selenium.WebDriverException: 'Error: Argument
to isShown must be of type Element' when calling method: [wdIMouse::doubleClick]
Build info: version: '2.2.0', revision: '13073', time: '2011-07-26 00:54:48'
System info: os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1', java.version:
'1.6.0_26'
Driver info: driver.version: RemoteWebDriver
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
    at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:131)
    at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:105)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:405)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:409)
    at org.openqa.selenium.remote.RemoteWebDriver$RemoteMouse.doubleClick(RemoteWebDriver.java:678)
    at org.openqa.selenium.interactions.DoubleClickAction.perform(DoubleClickAction.java:38)
    at org.openqa.selenium.interactions.CompositeAction.perform(CompositeAction.java:31)

Reported by rostislav.matl on 2011-07-28 14:28:50

lukeis commented 8 years ago
Context click doesn't work either.

Reported by kovyar on 2011-08-05 13:08:46

lukeis commented 8 years ago
The behaviour is the same in version 2.4. 

Reported by rostislav.matl on 2011-08-22 14:50:40

lukeis commented 8 years ago
This should be working with the IE driver on version 2.5. The code for supporting this
functionality in Firefox is under review and will be committed soon.

Reported by eran.mes on 2011-08-22 17:02:49

lukeis commented 8 years ago
Selenium 2.5 - confirmed that it works in MSIE, no change for Firefox.

Reported by rostislav.matl on 2011-09-12 14:31:19

lukeis commented 8 years ago
Not sure if it's the same issue, but using trunk today, double click with native events
returns an invalid response (status code is missing):

-> POST session/95c6a3bd-dade-403a-a19e-b43593ff6d15/doubleclick
<- {"name":"mouseDoubleClick","sessionId":"95c6a3bd-dade-403a-a19e-b43593ff6d15","value":{"message":"events.doubleClick
is not a function","stackTrace":[{"fileName":"file:///C:/Users/jari/AppData/Local/Temp/webdriver-profile20110913-544-1tsg4p8/extensions/fxdriver@googlecode.com/components/driver-component.js
-> file:///C:/Users/jari/AppData/Local/Temp/webdriver-profile20110913-544-1tsg4p8/extensions/fxdriver@googlecode.com/components/firefoxDriver.js","lineNumber":1281},{"fileName":"file:///C:/Users/jari/AppData/Local/Temp/webdriver-profile20110913-544-1tsg4p8/extensions/fxdriver@googlecode.com/components/nsCommandProcessor.js","lineNumber":306},{"fileName":"file:///C:/Users/jari/AppData/Local/Temp/webdriver-profile20110913-544-1tsg4p8/extensions/fxdriver@googlecode.com/components/nsCommandProcessor.js","lineNumber":320},{"fileName":"file:///C:/Users/jari/AppData/Local/Temp/webdriver-profile20110913-544-1tsg4p8/extensions/fxdriver@googlecode.com/components/nsCommandProcessor.js","lineNumber":197},{"lineNumber":0}]}}

Reported by jari.bakken on 2011-09-13 20:18:30

lukeis commented 8 years ago
Could be because we have an outdated pre-built binary checked-in. I'll update the prebuilts
tomorrow.

Reported by eran.mes on 2011-09-13 20:37:03

lukeis commented 8 years ago
Implemented a while ago - this functionality should definitely work in 2.15.

Reported by eran.mes on 2012-01-04 11:27:15

lukeis commented 8 years ago
Just tested this with 2.16.1 and it definitely works with the following code! 

      Actions builder = new Actions(driver);
      Action doubleClick = builder.doubleClick(cell).build();
      doubleClick.perform();

Reported by stian.lindhom.lemontree.no on 2012-01-11 13:45:18

lukeis commented 8 years ago
This is NOT working for me with 2.16.1 using FF9

event_names.get(0).click();
Actions builder = new Actions(site.getDriver());
builder.doubleClick(event_names.get(0)).build().perform();

Getting the same exception as from comment #8

I step through with debugger and it clicks properly, but double click doesn't happen.

Reported by ccooper@co3sys.com on 2012-01-18 15:06:47

lukeis commented 8 years ago
This worked for me in C#:

Actions builder = new Actions(driver);
IAction doubleClick = builder.DoubleClick(cell).Build();
doubleClick.Perform();

Reported by drflava4u on 2012-01-18 17:12:51

lukeis commented 8 years ago
This isn't working for me.  I'm using 2.16.1, and I've tried both of the following in
FF 3.6 and 10:

new Actions(driver).doubleClick(hwdbgrid).perform();

 or

Actions builder = new Actions(driver);
Action doubleClick = builder.doubleClick(hwdbgrid).build();
doubleClick.perform();

Both produce the error:

Exception in thread "main" java.lang.ClassCastException: org.openqa.selenium.firefox.FirefoxDriver
cannot be cast to org.openqa.selenium.HasInputDevices
    at org.openqa.selenium.interactions.Actions.<init>(Actions.java:45)

Any new insights on this issue?  Any workarounds for Webdriver?

Reported by jlturner7 on 2012-03-01 00:23:29

lukeis commented 8 years ago
This issue is reproducible on Webdriver 2.24.1 with firefox 13.0.1

Reported by rajendra.gopal on 2012-07-12 14:27:47

lukeis commented 8 years ago
I downloaded Selenium Client Driver (Java - 2.25.0 - 2012-07-18) and can't write the
following java code:

Actions builder = new Actions(driver);
Action doubleClick = builder.doubleClick(element).build().perform();
Eclipse says: "Type mismatch: cannot convert from void to ExecProtos.ActionList.Action".

Is there any solution? Does it (doubleclick) work in Selenium IDE? I tried in Selenium
1.9.0 (firefox) as well, but the Command, "doubleClick" is doing NOTHING. 

Reported by troy04 on 2012-08-23 13:35:50

lukeis commented 8 years ago
Just found out:

In Selenium WebDriver (Java - 2.25.0 - 2012-07-18), the following code doesn't build:

WebDriver driver = new FirefoxDriver();
WebElement element = driver.findElement(By.xpath("yourpath"));
Actions builder = new Actions(driver);
Action doubleClick = builder.doubleClick(element).build().perform(); 
Eclipse says: "Type mismatch: cannot convert from void to ExecProtos.ActionList.Action".

However, the following works in Selenium WebDriver:

String baseUrl = "your url";    
String my_xpath = "your path";      
Selenium s = new WebDriverBackedSelenium(driver, baseUrl);  
s.doubleClick(("xpath=" + my_xpath));

Reported by troy04 on 2012-08-23 14:46:52

lukeis commented 8 years ago

Reported by luke.semerau on 2015-09-17 18:12:52