我需要使用HTML单元从Java程序中单击,按下代码中的按钮:
<html>
<head/>
<body>
<div id="Change" class="test-frame">
<div class="middle">
<div class="r">
<div class="c">
<div class="c2">
<div class="test-window-content">
<div class="buttonRow">
<button name="save" type="button" onclick="disableButtons();doChangeCenter('/MakeChangesTestAction');" class="formButton">
Lock & Edit
</button>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>
我使用了以下代码,但返回了空指针异常:
HtmlPage page2 = (HtmlPage) webClient.getPage("http://test");
HtmlForm form2 = page2.getForms().get(0);
HtmlElement htmlElement = (HtmlElement) page2.getElementById("Change");
System.out.println(htmlElement.asXml());
谢谢!