Re: How do I execute JavaScript Function if I am using HttpUnitOptions.setScriptingEnabled(false)

Wolfgang Fahl <[email protected]> Fri, 19 Nov 2010 17:00:13 +0100
Newsgroups gmane.comp.web.httpunit.devel
Organization BITPlan GmbH
Message-ID <[email protected]>
This is a multi-part message in MIME format.
--===============1439206594204174586==
Content-Type: multipart/alternative;
	boundary="------------020200090604020906010608"

This is a multi-part message in MIME format.
--------------020200090604020906010608
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 8bit

Hi Amit,

You wrote:
 >please can anyone suggest how can I execute this JavaScript Function 
having HttpUnitOptions.setScriptingEnabled set to false.
You can't. Period.

Please read the FAQ javascript section for further info.

Cheers
   Wolfgang


Am 19.11.10 16:57, schrieb Amit Oberoi:
> Hi,
> I am testing a web application which is more of a message tracker. The 
> page I am stuck at present is a search page full of Java Script. To 
> avoid JavaScript exceptions I have used 
> HttpUnitOptions.setScriptingEnabled(false).
> My problem is the search button on which there is onClick event which 
> submits the form via a JavaScript Fucntion submitForm(); there is no 
> submit button for the search form except this search button. Because I 
> have disabled the scripting even if I call 
> button.doEventScript("onClick") the web page is not moving ahead. 
> please can anyone suggest how can I execute this JavaScript Function 
> having HttpUnitOptions.setScriptingEnabled set to false.
> My code snippet lokks like below:
> Button[] buttons = form.getButtons();
>    for(int i=0; i < buttons.length; i++) {
>     if(buttons[i].getAttribute("value").equalsIgnoreCase("search")) {
>      boolean check = 
> engine.createHandler(buttons[i]).doEventScript("onClick");
>      System.out.println(check);
>      response = b2bTracker.getCurrentPage();
>      System.out.println(response.getTitle());
>
>     }
> Submit Form finction looks like below
> function submitForm()
> {
>  var Submitt = "true";
>  var tBoxValue = document.getElementById("tbox").value;
>  var tAreaValue = document.getElementById("tarea").value;
>
>   if(document.getElementById("tbox").style.visibility == "visible")
>   {
>   if( !(tBoxValue == "") )
>   {
>    document.getElementById("searchContent").value = 
> document.getElementById("tbox").value;
>   }
>   else
>   {
>    alert("Enter the Search Content in the TextBox");
>    Submitt = "false";
>    document.getElementById("tbox").focus();
>   }
>  }
>  else if( document.getElementById("tarea").style.visibility == "visible")
>  {
>   if ( !(tAreaValue == "") )
>   {
>    document.getElementById("searchContent").value = 
> document.getElementById("tarea").value;
>   }
>   else
>   {
>    alert("Enter the Search Content in the TextArea");
>    Submitt = "false";
>    document.getElementById("tarea").focus();
>   }
>  }
>
>  auditLog = document.getElementById("audit").checked;
>  errorLog = document.getElementById("error").checked;
>  debugLog = document.getElementById("debug").checked;
>
>  if(auditLog == false && errorLog == false && debugLog == false)
>  {
>   alert("Please Select atleast One type of LOG");
>   Submitt = "false";
>  }
>  else
>  {
>   document.getElementById("searchInAuditLog").value = auditLog;
>   document.getElementById("searchInErrorLog").value = errorLog;
>   document.getElementById("searchInDebugLog").value = debugLog;
>  }
>
>  startDate = document.getElementById("txtStartDate").value;
>  endDate = document.getElementById("txtEndDate").value;
>
>  if(GetDate(startDate) > GetDate(endDate))
>  {
>   alert("StartDate shoudn't be greater than the EndDate");
>   Submitt = "false";
>  }
>
> document.getElementById("searchInZipFile").value 
> = document.getElementById("srchInZipFile").checked;
>
>
>  if(Submitt == "true")
>  {
>   document.searchForm.action = "mtracker.do";
>   document.searchForm.submit();
>  }
>
> }
> Thanks in antocipation of a positive response.
> Regards
> Amit
>
>
> ------------------------------------------------------------------------------
> Beautiful is writing same markup. Internet Explorer 9 supports
> standards for HTML5, CSS3, SVG 1.1,  ECMAScript5, and DOM L2&  L3.
> Spend less time writing and  rewriting code and more time creating great
> experiences on the web. Be a part of the beta today
> http://p.sf.net/sfu/msIE9-sfdev2dev
>
>
> _______________________________________________
> Httpunit-develop mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/httpunit-develop

-- 

BITPlan - smart solutions
Wolfgang Fahl
Pater-Delp-Str. 1, D-47877 Willich Schiefbahn
Tel. +49 2154 811-480, Fax +49 2154 811-481
Web: http://www.bitplan.de
BITPlan GmbH, Willich - HRB 6820 Krefeld, Steuer-Nr.: 10258040548, Geschäftsführer: Wolfgang Fahl


--------------020200090604020906010608
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#ffffff" text="#000000">
    Hi Amit,<br>
    <br>
    You wrote:<br>
    &gt;please can anyone suggest how can I execute this JavaScript
    Function having HttpUnitOptions.setScriptingEnabled set to false.<br>
    You can't. Period.<br>
    <br>
    Please read the FAQ javascript section for further info.<br>
    <br>
    Cheers<br>
    &nbsp; Wolfgang<br>
    <br>
    <br>
    Am 19.11.10 16:57, schrieb Amit Oberoi:
    <blockquote cite="mid:[email protected]"
      type="cite">
      <style type="text/css"><!-- DIV {margin:0px;} --></style>
      <div style="font-family: times new roman,new york,times,serif;
        font-size: 12pt;">
        <div>Hi,</div>
        <div>I am testing a web application which is more of a message
          tracker. The page I am stuck at present is a search page full
          of Java Script. To avoid JavaScript exceptions I have used
          HttpUnitOptions.setScriptingEnabled(false).</div>
        <div>My problem is the search button on which there is onClick
          event which submits the form via a JavaScript Fucntion
          submitForm(); there is no submit button for the search form
          except this search button. Because I have disabled the
          scripting even if I call button.doEventScript("onClick") the
          web page is not moving ahead. please can anyone suggest how
          can I execute this JavaScript Function having
          HttpUnitOptions.setScriptingEnabled set to false.</div>
        <div>My code snippet lokks like below:</div>
        <div>Button[] buttons = form.getButtons();<br>
          &nbsp;&nbsp;&nbsp;for(int i=0; i &lt; buttons.length; i++) {<br>
          &nbsp;&nbsp;&nbsp;&nbsp;if(buttons[i].getAttribute("value").equalsIgnoreCase("search"))
          {<br>
          &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;boolean check =
          engine.createHandler(buttons[i]).doEventScript("onClick");<br>
          &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.out.println(check);<br>
          &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;response = b2bTracker.getCurrentPage();<br>
          &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.out.println(response.getTitle());<br>
          &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>
          &nbsp;&nbsp;&nbsp;&nbsp;}</div>
        <div>Submit Form finction looks like below</div>
        <div>function submitForm()<br>
          {<br>
          &nbsp;var Submitt = "true";<br>
          &nbsp;var tBoxValue = document.getElementById("tbox").value;<br>
          &nbsp;var tAreaValue = document.getElementById("tarea").value;<br>
          &nbsp;<br>
          &nbsp; if(document.getElementById("tbox").style.visibility ==
          "visible")<br>
          &nbsp; {<br>
          &nbsp;&nbsp;if( !(tBoxValue == "") )<br>
          &nbsp;&nbsp;{<br>
          &nbsp;&nbsp;&nbsp;document.getElementById("searchContent").value =
          document.getElementById("tbox").value;<br>
          &nbsp;&nbsp;}<br>
          &nbsp;&nbsp;else<br>
          &nbsp;&nbsp;{<br>
          &nbsp;&nbsp;&nbsp;alert("Enter the Search Content in the TextBox");<br>
          &nbsp;&nbsp;&nbsp;Submitt = "false";<br>
          &nbsp;&nbsp;&nbsp;document.getElementById("tbox").focus();<br>
          &nbsp;&nbsp;}<br>
          &nbsp;}<br>
          &nbsp;else if( document.getElementById("tarea").style.visibility ==
          "visible")<br>
          &nbsp;{<br>
          &nbsp;&nbsp;if ( !(tAreaValue == "") )<br>
          &nbsp;&nbsp;{<br>
          &nbsp;&nbsp;&nbsp;document.getElementById("searchContent").value =
          document.getElementById("tarea").value;<br>
          &nbsp;&nbsp;}<br>
          &nbsp;&nbsp;else<br>
          &nbsp;&nbsp;{<br>
          &nbsp;&nbsp;&nbsp;alert("Enter the Search Content in the TextArea");<br>
          &nbsp;&nbsp;&nbsp;Submitt = "false";<br>
          &nbsp;&nbsp;&nbsp;document.getElementById("tarea").focus();<br>
          &nbsp;&nbsp;}<br>
          &nbsp;}<br>
          &nbsp;<br>
          &nbsp;auditLog = document.getElementById("audit").checked;<br>
          &nbsp;errorLog = document.getElementById("error").checked;<br>
          &nbsp;debugLog = document.getElementById("debug").checked;<br>
          &nbsp;<br>
          &nbsp;if(auditLog == false &amp;&amp; errorLog == false&nbsp; &amp;&amp;
          debugLog == false)<br>
          &nbsp;{<br>
          &nbsp;&nbsp;alert("Please Select atleast One type of LOG");<br>
          &nbsp;&nbsp;Submitt = "false";<br>
          &nbsp;}<br>
          &nbsp;else<br>
          &nbsp;{<br>
          &nbsp;&nbsp;document.getElementById("searchInAuditLog").value =
          auditLog;<br>
          &nbsp;&nbsp;document.getElementById("searchInErrorLog").value =
          errorLog;<br>
          &nbsp;&nbsp;document.getElementById("searchInDebugLog").value =
          debugLog;<br>
          &nbsp;}<br>
          &nbsp;<br>
          &nbsp;startDate = document.getElementById("txtStartDate").value;<br>
          &nbsp;endDate = document.getElementById("txtEndDate").value;<br>
          &nbsp;<br>
          &nbsp;if(GetDate(startDate) &gt; GetDate(endDate))<br>
          &nbsp;{<br>
          &nbsp;&nbsp;alert("StartDate shoudn't be greater than the EndDate");<br>
          &nbsp;&nbsp;Submitt = "false";<br>
          &nbsp;}<br>
          &nbsp;<br>
          document.getElementById("searchInZipFile").value
          =&nbsp;document.getElementById("srchInZipFile").checked;<br>
          &nbsp;<br>
          &nbsp;<br>
          &nbsp;if(Submitt == "true")<br>
          &nbsp;{<br>
          &nbsp;&nbsp;document.searchForm.action = "mtracker.do";<br>
          &nbsp;&nbsp;document.searchForm.submit();<br>
          &nbsp;}<br>
          &nbsp;<br>
          }</div>
        <div>&nbsp;</div>
        <div>Thanks in antocipation of a positive response.</div>
        <div>&nbsp;</div>
        <div>Regards</div>
        <div>&nbsp;</div>
        <div>Amit</div>
      </div>
      <br>
      <pre wrap="">
<fieldset class="mimeAttachmentHeader"></fieldset>
------------------------------------------------------------------------------
Beautiful is writing same markup. Internet Explorer 9 supports
standards for HTML5, CSS3, SVG 1.1,  ECMAScript5, and DOM L2 &amp; L3.
Spend less time writing and  rewriting code and more time creating great
experiences on the web. Be a part of the beta today
<a class="moz-txt-link-freetext" href="http://p.sf.net/sfu/msIE9-sfdev2dev">http://p.sf.net/sfu/msIE9-sfdev2dev</a></pre>
      <pre wrap="">
<fieldset class="mimeAttachmentHeader"></fieldset>
_______________________________________________
Httpunit-develop mailing list
<a class="moz-txt-link-abbreviated" href="mailto:[email protected]">[email protected]</a>
<a class="moz-txt-link-freetext" href="https://lists.sourceforge.net/lists/listinfo/httpunit-develop">https://lists.sourceforge.net/lists/listinfo/httpunit-develop</a>
</pre>
    </blockquote>
    <br>
    <pre class="moz-signature" cols="72">-- 

BITPlan - smart solutions
Wolfgang Fahl
Pater-Delp-Str. 1, D-47877 Willich Schiefbahn
Tel. +49 2154 811-480, Fax +49 2154 811-481
Web: <a class="moz-txt-link-freetext" href="http://www.bitplan.de">http://www.bitplan.de</a>
BITPlan GmbH, Willich - HRB 6820 Krefeld, Steuer-Nr.: 10258040548, Gesch&auml;ftsf&uuml;hrer: Wolfgang Fahl </pre>
  </body>
</html>

--------------020200090604020906010608--


--===============1439206594204174586==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

------------------------------------------------------------------------------
Beautiful is writing same markup. Internet Explorer 9 supports
standards for HTML5, CSS3, SVG 1.1,  ECMAScript5, and DOM L2 & L3.
Spend less time writing and  rewriting code and more time creating great
experiences on the web. Be a part of the beta today
http://p.sf.net/sfu/msIE9-sfdev2dev
--===============1439206594204174586==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
Httpunit-develop mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/httpunit-develop

--===============1439206594204174586==--