views:

18

answers:

1

Hi, I'm 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:

  1. 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.

  2. How do you perform a double click in Selenium 2.0/Webdriver?

Thank you in advance for any assistance.

A: 
  1. You should click on the table cell (<td>) element

  2. 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.

ZloiAdun