Bilow Yuriy
Bilow Yuriy

Reputation: 1319

How can I simultaneously perform 'CTRL + Enter ' in Selenium WebDriver?

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

Answers (3)

Charlie 木匠
Charlie 木匠

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

Revanth Kumar
Revanth Kumar

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

Abhishek Singh
Abhishek Singh

Reputation: 9765

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

will do the work for you..

Upvotes: 6

Related Questions