Home > Software design >  How to properly make double click with ctrl button pressed in selenium (java script)
How to properly make double click with ctrl button pressed in selenium (java script)

Time:10-16

I'm trying to test my web app functionality, when element is double clicked and control button is pressed. I'm using selenium in nodejs. The command I use to do it is as follows:

const actions = driver.actions({async: true});
await actions.keyDown(Key.CONTROL).doubleClick(element2clickOn).keyUp(Key.CONTROL).perform();

In webbrowser logs I can see that the double click event is there, however the ctrlKey member of the event is false. If I put Key.SHIFT or Key.ALT then and try it, then I see that corresponding shiftKey or altKey of the event are set to true.

Anyone knows if there is a bug or I'm doing something wrong?

More details: node version 18.6 npm version 8.14 selenium-webdriver ^4.1.1 Tested usig edge and chrome webdrivers.

CodePudding user response:

After reporting it and checking selenium test cases, it turned out that to make the control press work properly, it's enough to remove {async:true} parameter in the actions construction method. So code:

const actions = driver.actions();
await actions.keyDown(Key.CONTROL).doubleClick(element2clickOn).keyUp(Key.CONTROL).perform();

works properly for my case.

Bug reported in selenium and link to test cases is here: https://github.com/SeleniumHQ/selenium/issues/11127

  • Related