By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
460,044 Members | 1,248 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 460,044 IT Pros & Developers. It's quick & easy.

Htmlunit JavaScript response is not being reflected

P: 1
I am trying to to post a comment from a webpage.. Comment web page has textarea and a button type input

here is html of textarea

Expand|Select|Wrap|Line Numbers
  1. <textarea class="aui-field-input aui-field-input-text" id="_33_wgdr_postReplyBody0" name="_33_postReplyBody0" wrap="soft" style="height: 100px; width: 500px;"></textarea>
and here is the way I am writing some text into textarea

Expand|Select|Wrap|Line Numbers
  1. HtmlTextArea hta = (HtmlTextArea) commentPage.getElementsByName("_33_postReplyBody0").get(0);
  2. hta.setAttribute("value", "This Is Generated Text");
Button input in html page is

Expand|Select|Wrap|Line Numbers
  1.   <input class="aui-button-input" onclick="wgdr_postReply(0);" type="button" value="Reply" id="_33_wgdr_postReplyButton0"/>
I have tried to click on button in either this way

Expand|Select|Wrap|Line Numbers
  1.  HtmlButtonInput hbi = (HtmlButtonInput) commentPage.getByXPath("//*[@value='Reply' and @type='button']").get(0);
  2.     HtmlPage test = hbi.click();
or this way

Expand|Select|Wrap|Line Numbers
  1.   HtmlButtonInput hbi = (HtmlButtonInput) commentPage.getByXPath("//*[@value='Reply' and @type='button']").get(0);
  2.   String functName = hbi.getAttribute("onclick");
  3.   ScriptResult scriptResult = commentPage.executeJavaScript(functName);
as a result my webpage and thus database should have a new comment "This Is Generated Text" which is not the case at all... I have initialized my webclient in following way:

Expand|Select|Wrap|Line Numbers
  1. WebClient webClient = new WebClient(BrowserVersion.INTERNET_EXPLORER_8);
  2. webClient.setJavaScriptEnabled(true);
  3.     webClient.setThrowExceptionOnScriptError(false);
  4.     webClient.setThrowExceptionOnFailingStatusCode(false);
  5.     webClient.setPrintContentOnFailingStatusCode(false);
  6.     webClient.setTimeout(60000);
  7.     webClient.setJavaScriptTimeout(60000);
  8.     webClient.waitForBackgroundJavaScript(10000);
I have been digging into this since two days with no fruitful outcomes...Please post your thoughts Thanks, -Asrar
Nov 15 '12 #1
Share this Question
Share on Google+
1 Reply


Dormilich
Expert Mod 5K+
P: 8,639
Please post your thoughts
prime thought, how does the generated HTML/JS code look like?

btw, Id be interested where JavaScript comes into play.
Nov 15 '12 #2

Post your reply

Sign in to post your reply or Sign up for a free account.