tags:

views:

161

answers:

1

In order to edit the content of a cell you need to double click on it. However with webdriver they don't have a doubleclick function in the api. How else can I change the content of the cell?

+1  A: 

What grid are you asking about? For most grids there's a JavaScript function to start editing a cell.

Anyway you can fire a double click with a JavaScript. Assuming the the element is a IWebElement on which you would like to double click:

For the InternetExplorerDriver:

((IJavascriptExecutor)driver).ExecuteScript(
    "arguments[0].fireEvent('ondblclick')", element);

For the FirefoxDriver and 'ChromeDriver':

((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);", element);
ZloiAdun
The grid's class is "x-grid3"
Reflux
If it is an ExtJS Grid, then it has a method startEditing( Number rowIndex, Number colIndex ) which can be fired
ZloiAdun