我正在使用 Java Selenium,并使用 Firefox 驱动程序进行测试。
我想将 Ctrl + - 发送到我的 Firefox 浏览器。
这是我的代码:
Common.myPrint(thisClass + " *** zoomOut ***");
Actions actionObject = new Actions(driver);
try {
actionObject.keyDown(Keys.CONTROL).sendKeys(Keys.CONTROL).keyUp(Keys.SUBTRACT).perform();
// reset this counter - basis for request counter
global.variables.dataTotalCount = 0;
return true;
} catch (Exception e) {
int errorCode = 1525182195;
System.err.println(thisClass + " error code: " + errorCode + " Exception: " + e.getMessage());
return false;
}
我收到此错误消息:异常:按键向下/向上事件仅对修饰键有意义。
这一切都很好,但是我如何发送 Ctrl & -(以减小字体大小)
最佳答案
尝试和弦法
String selectkeys= Keys.chord(Keys.CONTROL, Keys.SUBTRACT);
关于java - 异常: Key Down/Up events only make sense for modifier keys,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50451815/