当调用robot类时,在eclipse中抛出了无效的StackMap错误JVMCFRE006

时间:2017-05-10 10:14:12

标签: java selenium-webdriver popup jvm

代码:

public int close(WebDriver driver) {
        int status=0;
        try{
            Robot robot=new Robot();
            robot.keyPress(KeyEvent.VK_ESCAPE);
            robot.keyRelease(KeyEvent.VK_ESCAPE);
            status=1;

        }

        catch(Exception e)
         {
             e.printStackTrace();
         }
        return status;
}

当调用上面的方法时,我收到以下错误消息。由于机器人类显示以下错误,如果我跳过上面的方法框架工作正常。我正在使用机器人类关闭Windows打印弹出窗口。

目前正在使用jre 1.7版本。

Exception in thread "main" java.lang.VerifyError:JVMCFRE006 invalid StackMap/StackMapTable attribute; class=java/awt/Toolkit, method=createComponent(Ljava/awt/Component;)Ljava/awt/peer/LightweightPeer;, pc=21
    at com.ibm.oti.vm.VM.findClassOrNull(Native Method)
    at com.ibm.oti.vm.BootstrapClassLoader.loadClass(BootstrapClassLoader.java:62)
    at com.ibm.oti.vm.VM.findClassOrNull(Native Method)
    at com.ibm.oti.vm.BootstrapClassLoader.loadClass(BootstrapClassLoader.java:62)
    at com.ibm.oti.vm.VM.findClassOrNull(Native Method)
    at com.ibm.oti.vm.BootstrapClassLoader.loadClass(BootstrapClassLoader.java:62)
    at sun.awt.Win32GraphicsEnvironment.<clinit>(Win32GraphicsEnvironment.java:77)
    at java.lang.J9VMInternals.initializeImpl(Native Method)
    at java.lang.J9VMInternals.initialize(J9VMInternals.java:228)
    at java.lang.Class.forNameImpl(Native Method)
    at java.lang.Class.forName(Class.java:139)
    at java.awt.GraphicsEnvironment.createGE(GraphicsEnvironment.java:113)
    at java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment(GraphicsEnvironment.java:92)
    at java.awt.Robot.<init>(Robot.java:107)

1 个答案:

答案 0 :(得分:0)

尝试使用以下方法使用ESCAPE键关闭弹出窗口。

public void closePopupByEscapeKey() throws Exception{
    try{
        Actions action = new Actions(Webdriver);
        action.sendKeys(Keys.ESCAPE).build();
        action.perform();
    }catch(Exception e){
        throw e;
    }
}