1

以下のコードを実行すると、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)
4

2 に答える 2

0

昨日、私はほとんど同じ問題を抱えていましたが、奇妙に見えますが、実行するのではなくデバッグするか、送信ボタンをクリックする前に遅延を追加してください

    Thread.sleep(10000);

また、この回答もご覧くださいAssertionViolatedException

于 2014-09-18T09:48:17.330 に答える