我在 WinXP32 上使用 Selenium 2.28 和 IE8。我需要能够将以下键盘命令发送到我的网页:ALT + k
以下在 Chrome 和 Firefox17 中完美运行:
- Chrome:
Actions builder = new Actions(driver);
builder.sendKeys(Keys.ALT, "k").build().perform();
- Firefox 17 (requires extra command key for same effect):
Actions builder = new Actions(driver);
builder.sendKeys(Keys.SHIFT, Keys.ALT, "k").build().perform();
我在 IE 中尝试了以下所有方法,但均未成功:
- builder.sendKeys(Keys.ALT, "k").build().perform();
- builder.sendKeys(Keys.ALT, Keys.SHIFT, "k").build().perform();
- builder.sendKeys(Keys.chord(Keys.ALT, "k")).build().perform();
- builder.sendKeys(Keys.chord(Keys.SHIFT, Keys.ALT, "k")).build().perform();
- builder.keyDown(Keys.ALT).sendKeys("k").build().perform();
- builder.keyDown(Keys.ALT).sendKeys("k").keyUp(Keys.ALT).build().perform();
- builder.keyDown(Keys.SHIFT).keyDown(Keys.ALT).sendKeys("k").build().perform();
- builder.keyDown(Keys.SHIFT).keyDown(Keys.ALT).sendKeys("k").keyUp(Keys.ALT).keyUp(Keys.SHIFT).build().perform();
关于如何实现我想要的任何建议?