0

I have a shortcut with holding keys CRTL + ALT + E + CLICK on button. In selenium I'm trying to do this with like below var actions = new Actions(Driver) then actions.KeyDown(Keys.Control + Keys.Alt).SendKeys("E").Click(Button).Perform();

Method SendKeys("E") is doing KeyDown and then KeyUp and that's why, I can not create correct shortcut with click because I'm not holding "E".

Any tips how to perform KeyDown("E") ?

EDIT: actions.ClickAndHold(ActionButtons.Edit.Init()); actions.SendKeys(Keys.Control + Keys.Alt + "e" + Keys.Clear); actions.Build().Perform();

Also I find other way with ClickAndHold(). The principle is click and send sequence of keys and in the same time release click. Any suggestions, how to do that ?

Micky
  • 125
  • 1
  • 7
  • Use Robot class ,For Keyboard events keypress & keyRelease to press & release keys. – Sneha Shinde May 25 '18 at 06:48
  • Can you be more specific ? Can you send a reference please ? – Micky May 25 '18 at 07:11
  • You need to import java.awt.Robot;Robot rb = new Robot(); rb.keyPress(KeyEvent.VK_CONTROL); rb.keyPress(KeyEvent.VK_A);This code to press Ctrl + A keys – Sneha Shinde May 25 '18 at 07:15
  • Maybe in java but I'm using c# – Micky May 25 '18 at 07:17
  • for reference 1) https://stackoverflow.com/questions/11402643/sendkey-send-not-working/11403269#11403269 2)https://social.msdn.microsoft.com/Forums/en-US/a4ff3770-c384-4526-9099-cf134be4dfcc/javaawtrobot-equivalent-in-net?forum=netfxbcl – Sneha Shinde May 25 '18 at 07:21

1 Answers1

0

Try below code

 actions.SendKeys(Keys.Control + Keys.Alt + "e").Click(Button).Perform();
Prany
  • 2,078
  • 2
  • 13
  • 31