How to send keyboard shortcut ALT SHIFT z (hotkey) with Selenium2?

前端 未结 3 1137
感情败类
感情败类 2020-12-05 15:47

I am trying send shortcut with Actions.sendKeys, but it isn\'t work.

(New Actions(driver)).SendKeys(Keys.ALT, Keys.SHIFT, \"z\");
相关标签:
3条回答
  • 2020-12-05 16:25

    You can check this question to refer about this - Key press in (Ctrl+A) Selenium WebDriver

    Check the answer which uses the chord method, in your case you can do this -

    String selectAll = Keys.chord(Keys.ALT, Keys.SHIFT,"z");
    driver.findElement(By.tagName("html")).sendKeys(selectAll);
    
    0 讨论(0)
  • 2020-12-05 16:35

    This can also be done using Actions keyUp and keyDown funcitons.

    WebDriver driver = new FirefoxDriver();
    Actions keyAction = new Actions(driver);     
    keyAction.keyDown(Keys.ALT).keyDown(Keys.SHIFT).sendKeys("z").keyUp(Keys.ALT).keyUp(Keys.SHIFT).perform();
    
    0 讨论(0)
  • 2020-12-05 16:38

    Try it:

    SendKeys.SendWait("%+z")
    
    0 讨论(0)
提交回复
热议问题