发现HTML单元:内部错误:哎呀!退出

时间:2014-09-18 02:17:52

标签: htmlunit htmlunit-driver

我是HTMLUNIT的新用户,当我运行以下代码时。

import com.gargoylesoftware.htmlunit.WebClient;
import com.gargoylesoftware.htmlunit.html.HtmlForm;
import com.gargoylesoftware.htmlunit.html.HtmlPage;
import com.gargoylesoftware.htmlunit.html.HtmlSubmitInput;
import com.gargoylesoftware.htmlunit.html.HtmlTextInput;

public class WeBrowser {

    public void homePage() throws Exception {

        final WebClient webClient = new WebClient();
        // Get the first page
        final HtmlPage page1 = webClient.getPage("http://some_url");
        // Get the form that we are dealing with and within that form,
        // find the submit button and the field that we want to change.
        final HtmlForm form = page1.getFormByName("myform");
        final HtmlSubmitInput button = form.getInputByName("submitbutton");
        final HtmlTextInput textField = form.getInputByName("userid");
        // Change the value of the text field
        textField.setValueAttribute("root");
        // Submit the form by clicking the button and get back the second page.
        final HtmlPage page2 = button.click();

        webClient.closeAllWindows();
    }
}

它显示以下错误:

Exception in thread "main" org.apache.bcel.verifier.exc.AssertionViolatedException: 

FOUND:
INTERNAL ERROR: Oops!
Exiting!!

at org.apache.bcel.verifier.exc.AssertionViolatedException.main(AssertionViolatedException.java:102)

2 个答案:

答案 0 :(得分:0)

昨天我遇到了几乎同样的问题,虽然它看起来很奇怪但是尝试通过调试而不是运行,或者在点击提交按钮之前添加一些延迟

    Thread.sleep(10000);

还要看一下这个答案AssertionViolatedException

答案 1 :(得分:0)

我使用eclipse运行以前工作正常的java代码时遇到了同样的错误。在使用'project>> clean>>所有项目'后,问题就消失了。不知道触发它的是什么,但工作区中的所有项目都受到了影响。