我正试图从网页发表评论..评论网页有textarea和按钮类型输入
这里是textarea的html
<textarea class="aui-field-input aui-field-input-text" id="_33_wgdr_postReplyBody0" name="_33_postReplyBody0" wrap="soft" style="height: 100px; width: 500px;"></textarea>
这是我将一些文字写入textarea的方式
HtmlTextArea hta = (HtmlTextArea) commentPage.getElementsByName("_33_postReplyBody0").get(0);
hta.setAttribute("value", "This Is Generated Text");
html页面中的按钮输入是
<input class="aui-button-input" onclick="wgdr_postReply(0);" type="button" value="Reply" id="_33_wgdr_postReplyButton0"/>
我试图以这种方式点击按钮
HtmlButtonInput hbi = (HtmlButtonInput) commentPage.getByXPath("//*[@value='Reply' and @type='button']").get(0);
HtmlPage test = hbi.click();
或者这样
HtmlButtonInput hbi = (HtmlButtonInput) commentPage.getByXPath("//*[@value='Reply' and @type='button']").get(0);
String functName = hbi.getAttribute("onclick");
ScriptResult scriptResult = commentPage.executeJavaScript(functName);
因此我的网页和数据库应该有一个新的评论“这是生成的文本”,根本不是这样的... 我已按照以下方式初始化了我的webclient:
WebClient webClient = new WebClient(BrowserVersion.INTERNET_EXPLORER_8);
webClient.setJavaScriptEnabled(true);
webClient.setThrowExceptionOnScriptError(false);
webClient.setThrowExceptionOnFailingStatusCode(false);
webClient.setPrintContentOnFailingStatusCode(false);
webClient.setTimeout(60000);
webClient.setJavaScriptTimeout(60000);
webClient.waitForBackgroundJavaScript(10000);
自从两天以来我一直在深入研究这个问题并没有取得丰硕成果......请发表您的想法 谢谢, -Asrar