How to keyPress + click with selenium -


I have a problem with my selenium code, the key is not running properly, press + click operation.

Examine the Jqueryui.com link and select the first 2 elements on the page.

I am using Selenium 2.23 and Firefox 10. My code is as follows (I have 4 different ways to do this work but no display was done):

FirefoxProfile Profile = New FirefoxProfile ();

Profile. SetOne Native Event (true); WebDrive Browser = New Firefox Driver (Profile); Browser.gate ("");

  verbs = a new verb;   

List element = Browser.Finded Elements (by.cssSelector ("ol # selectable li")); (Browser); A.keyDown (keys.CONTROL) .moveToElement (elements.get (0)) .click () .moveToElement (elements.get (1)) .click () .keyUp (Keys.CONTROL) .build () .form ( ); Keyboard Keyboard = ((HasInputDevices) Browser). GetKeyboard (); Keyboard.pressKey (Keys.CONTROL); & Lt; WebElement & gt; Select option = Browser.Finded Elements (by CCSSElectector ("OL selectable"); SelectOptions.get (1) .click (); SelectOptions.get (3) .click (); Keyboard.releaseKey (Keys.CONTROL);

  Action Builder = New Action (Browser); Builder.keyDown (elements.get (0), Keys.CONTROL). Click (elements.get (0)). Click (elements.get (1)) .keyup (Keys.CONTROL); Action Selection = Builder Build (); SelectMultiple.perform (); Robot robot = new robot (); Robot.delay (1000); Robot.keyPress (KeyEvent.CTRL_MASK); Elements.get (0) .click (); Elements.get (1) .click (); Robot.keyRelease (KeyEvent.CTRL_MASK); Browser.quit (); Can anyone help me with some other suggestions?   

I do not really know why none of your efforts works (especially First) Key stability is a mess.

Anyway, I'm able to do this work (on Windows XP):

  robot robot = new robot (); Robot.keyPress (KeyEvent.VK_CONTROL); Elements.get (0) .click (); Elements.get (1) .click (); Robot.keyRelease (KeyEvent.VK_CONTROL);    

Comments