Venkata Ramana
Venkata Ramana

Reputation: 31

How to click CTRL+P using Java and selenium web driver?

I am unable to send keyboard entry as CTRL+P using selenium. Please help.

My code looks like below: getWebElement("Registration").sendKeys(Keys.chord(Keys.CONTROL, "p"));

I have tried CTRL+A with the same code and it works without any issues.

Upvotes: 0

Views: 2230

Answers (2)

Gnk
Gnk

Reputation: 720

If you are trying to print, this is working for me

((JavascriptExecutor) driver).executeScript("print()");

Upvotes: 2

Infern0
Infern0

Reputation: 2814

Try with actions

Actions actions = new Actions(driver);
actions.sendKeys(Keys.chord(Keys.LEFT_CONTROL, "p")).build().perform();

Upvotes: 0

Related Questions