Reputation: 1319
How can I simultaneously perform Ctrl+Enter↵ in Selenium WebDriver? I tried this one:
body1.sendKeys(Keys.CONTROL + "ENTER");
But it doesn't work.
Upvotes: 2
Views: 11455
Reputation: 2400
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/
Upvotes: 0
Reputation: 837
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();
Upvotes: 1
Reputation: 9765
String keysPressed = Keys.chord(Keys.CONTROL, Keys.RETURN);
element.sendKeys(keysPressed) ;
will do the work for you..
Upvotes: 6