0

How to press Ctrl + S in Selenium Chrome Web Driver?

How to save PDF file in Selenium Chrome Web Driver?

Because its automatically opening in a new Chrome tab.

1

3 Answers 3

1

To click Ctrl+S, you can do it with Actions class

Actions actions=new Actions(driver);
actions.sendKeys(Keys.chord(Keys.chord(Keys.CONTROL+"S"))).build().perform();

Chord helps in simulating pressing many keys at once in. Hope it helps !

Sign up to request clarification or add additional context in comments.

Comments

0

You can use ActionBuilder for this below code is in Python just for basic idea ..

driver.action.key_down(:control)
         .send_keys("s")
         .key_up(:control)
         .perform`

Comments

0

you have to use robot class for that.

  1. import following jars:

    import java.awt.AWTException;   
    import java.awt.Robot;  
    import java.awt.event.KeyEvent; 
    
  2. Press the keys you want to use:

    Robot robot = new Robot();
    robot.keyPress(KeyEvent.VK_CONTROL);
    robot.keyPress(KeyEvent.VK_S);
    robot.keyRelease(KeyEvent.VK_CONTROL);
    robot.keyRelease(KeyEvent.VK_S);
    robot.keyPress(KeyEvent.VK_ENTER);
    robot.keyRelease(KeyEvent.VK_ENTER);
    
  3. Keys event will be performed

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.