Reputation: 31
I am using C# with Selenium 2.0 / Webdriver and I'm trying to simulate a double click on a table row that opens a new browser window.
I have two problems:
After locating the table row which has a unique classname (i.e. using findelement(By.classname("...")))
applying the click method (or select/submit) does not perform any action and complains about not being able to perform that kind action on the element in question.
How do you perform a double click in Selenium 2.0/Webdriver ?
Upvotes: 3
Views: 15479
Reputation: 4474
For double click you can perform following:
from selenium.webdriver import ActionChains
action_chains = ActionChains(driver)
action_chians.double_click(on_element).perform()
*where, on_element = element on which you want to double click*
I did this using python. and it worked :)
Upvotes: 5
Reputation: 17828
You should click on the table cell (<td>
) element
Double click is not yet implemented in WebDriver. See Issue #244 for the status. Also the comments to this issue contains a JavaScript that can be used to to the double click in Firefox.
For IE you will need to execute the following:
(IJavaScriptExecutor)driver).executeScript("arguments[0].fireEvent('ondblclick');", cell);
For the Firefox and Chrome:
(IJavaScriptExecutor)driver).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);", cell);
where the cell
is the web element on which you would like to execute the script.
Upvotes: 8