使用Keys.CTRL + t,没有在带有gecko驱动程序的Selenium 3.0中打开新选项卡
driver.findElement(By.cssSelector("body")).sendKeys(Keys.CONTROL +"t");
一旦我尝试了Robot,就像 -
try{
Robot robot = new Robot();
robot.keyPress(KeyEvent.VK_CONTROL);
robot.keyPress(KeyEvent.VK_T);
}catch (AWTException e){
e.printStackTrace(); // Or do whatever in here
}
我不确定这里的键(VK_CONTROL和VK_T),这是你必须找到的,但它对我有用。附:可能你必须在之后释放密钥。