我正在使用Selenium 2.28和WinXP32上的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();
有没有关于如何实现我想要的建议?