I am writing automated tests for a site at work and we have certain screens that when we send a specific set of keystrokes, a section of the page will become visible and allows us to see information related to pricing or a document.
I would like to automate this using WebDriver's KeyDown or SendKeys command but I have so far been unable to.
The command I am trying to automate is Control + Alt + "Double Click". This is the code I have, but I have tried other variations using SendKeys instead of KeyDown. I know that at least one of the keys is being pressed on the page because the text within the element highlights, mimicing either a control or alt click, and the double click is also firing correctly.
Actions builder = new Actions(this.driver);
builder.KeyDown(Keys.LeftControl);
builder.KeyDown(Keys.LeftAlt);
builder.DoubleClick(BrowserHelper.GetElement(this.driver, locator, additionalLocatorPath));
builder.KeyUp(Keys.LeftControl);
builder.KeyUp(Keys.LeftAlt).Build().Perform();
I am using the latest version of firefox with native events enabled and webdriver 2.20
UPDATE I wound up ditching the action builder and used the javascript executor.
string jsScript = "var doubleClickElement = document.getElementById('"+ locator + "'); if(document.createEventObject){var evt = document.createEventObject();evt.altKey = true;evt.ctrlKey = true;doubleClickElement.fireEvent('ondblclick', evt);}else{var evt = document.createEvent('MouseEvents');evt.initMouseEvent('dblclick', true, true, window, null, 1, 1, 1, 1, true, true, false, false, null, doubleClickElement);doubleClickElement.dispatchEvent(evt);}";
((IJavaScriptExecutor)this.driver).ExecuteScript(jsScript);