2

How can I simultaneously perform Ctrl+Enter↵ in Selenium WebDriver? I tried this one:

       body1.sendKeys(Keys.CONTROL + "ENTER");

But it doesn't work.

Cœur
  • 37,241
  • 25
  • 195
  • 267
Bilow Yuriy
  • 1,239
  • 3
  • 13
  • 20
  • Check : 1. http://stackoverflow.com/questions/1629053/typing-enter-return-key-in-selenium and, 2. http://stackoverflow.com/questions/11503736/key-press-in-selenium-webdriver – rags Aug 28 '13 at 12:02

3 Answers3

6
   String keysPressed =  Keys.chord(Keys.CONTROL, Keys.RETURN);
   element.sendKeys(keysPressed) ;

will do the work for you..

Abhishek Singh
  • 10,243
  • 22
  • 74
  • 108
1

This method uses actions instead of the chord function.

Actions action = new Actions(driver);
action.keyDown(Keys.CONTROL).keyDown(Keys.RETURN).keyUp(Keys.CONTROL).keyUp(Keys.RETURN).perform();
Revanth Kumar
  • 809
  • 12
  • 18
0
from selenium import webdriver

browser = webdriver.Chrome()

webdriver.ActionChains(browser).key_down(Keys.CONTROL).send_keys(Keys.ENTER).perform()

https://www.selenium.dev/documentation/webdriver/actions_api/keyboard/

Charlie 木匠
  • 2,234
  • 19
  • 19