How do I execute JavaScript Function if I am using HttpUnitOptions.setScriptingEnabled(false)
Amit Oberoi <[email protected]> Fri, 19 Nov 2010 21:27:25 +0530 (IST)
| Newsgroups | gmane.comp.web.httpunit.devel |
|---|---|
| Message-ID | <[email protected]> |
--===============8007794472716983532==
Content-Type: multipart/alternative; boundary="0-1007767444-1290182245=:89134"
--0-1007767444-1290182245=:89134
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: quoted-printable
Hi,=0AI am testing a web application which is more of a message tracker. Th=
e page I am =0Astuck at present is a search page full of Java Script. To av=
oid JavaScript =0Aexceptions I have used HttpUnitOptions.setScriptingEnable=
d(false).=0AMy problem is the search button on which there is onClick event=
which submits =0Athe form via a JavaScript Fucntion submitForm(); there is=
no submit button for =0Athe search form except this search button. Because=
I have disabled the scripting =0Aeven if I call button.doEventScript("onCl=
ick") the web page is not moving ahead. =0Aplease can anyone suggest how ca=
n I execute this JavaScript Function having =0AHttpUnitOptions.setScripting=
Enabled set to false.=0AMy code snippet lokks like below:=0AButton[] button=
s =3D form.getButtons();=0A=A0=A0=A0for(int i=3D0; i < buttons.length; i++)=
{=0A=A0=A0=A0=A0if(buttons[i].getAttribute("value").equalsIgnoreCase("sear=
ch")) {=0A=A0=A0=A0=A0=A0boolean check =3D engine.createHandler(buttons[i])=
.doEventScript("onClick");=0A=A0=A0=A0=A0=A0System.out.println(check);=0A=
=A0=A0=A0=A0=A0response =3D b2bTracker.getCurrentPage();=0A=A0=A0=A0=A0=A0S=
ystem.out.println(response.getTitle());=0A=A0=A0=A0=A0=A0=A0=0A=A0=A0=A0=A0=
}=0ASubmit Form finction looks like below=0Afunction submitForm()=0A{=0A=A0=
var Submitt =3D "true";=0A=A0var tBoxValue =3D document.getElementById("tbo=
x").value;=0A=A0var tAreaValue =3D document.getElementById("tarea").value;=
=0A=A0=0A=A0 if(document.getElementById("tbox").style.visibility =3D=3D "vi=
sible")=0A=A0 {=0A=A0=A0if( !(tBoxValue =3D=3D "") )=0A=A0=A0{=0A=A0=A0=A0d=
ocument.getElementById("searchContent").value =3D =0Adocument.getElementByI=
d("tbox").value;=0A=A0=A0}=0A=A0=A0else=0A=A0=A0{=0A=A0=A0=A0alert("Enter t=
he Search Content in the TextBox");=0A=A0=A0=A0Submitt =3D "false";=0A=A0=
=A0=A0document.getElementById("tbox").focus();=0A=A0=A0}=0A=A0}=0A=A0else i=
f( document.getElementById("tarea").style.visibility =3D=3D "visible")=0A=
=A0{=0A=A0=A0if ( !(tAreaValue =3D=3D "") )=0A=A0=A0{=0A=A0=A0=A0document.g=
etElementById("searchContent").value =3D =0Adocument.getElementById("tarea"=
).value;=0A=A0=A0}=0A=A0=A0else=0A=A0=A0{=0A=A0=A0=A0alert("Enter the Searc=
h Content in the TextArea");=0A=A0=A0=A0Submitt =3D "false";=0A=A0=A0=A0doc=
ument.getElementById("tarea").focus();=0A=A0=A0}=0A=A0}=0A=A0=0A=A0auditLog=
=3D document.getElementById("audit").checked;=0A=A0errorLog =3D document.g=
etElementById("error").checked;=0A=A0debugLog =3D document.getElementById("=
debug").checked;=0A=A0=0A=A0if(auditLog =3D=3D false && errorLog =3D=3D fal=
se=A0 && debugLog =3D=3D false)=0A=A0{=0A=A0=A0alert("Please Select atleast=
One type of LOG");=0A=A0=A0Submitt =3D "false";=0A=A0}=0A=A0else=0A=A0{=0A=
=A0=A0document.getElementById("searchInAuditLog").value =3D auditLog;=0A=A0=
=A0document.getElementById("searchInErrorLog").value =3D errorLog;=0A=A0=A0=
document.getElementById("searchInDebugLog").value =3D debugLog;=0A=A0}=0A=
=A0=0A=A0startDate =3D document.getElementById("txtStartDate").value;=0A=A0=
endDate =3D document.getElementById("txtEndDate").value;=0A=A0=0A=A0if(GetD=
ate(startDate) > GetDate(endDate))=0A=A0{=0A=A0=A0alert("StartDate shoudn't=
be greater than the EndDate");=0A=A0=A0Submitt =3D "false";=0A=A0}=0A=A0=
=0Adocument.getElementById("searchInZipFile").value =0A=3D=A0document.getEl=
ementById("srchInZipFile").checked;=0A=A0=0A=A0=0A=A0if(Submitt =3D=3D "tru=
e")=0A=A0{=0A=A0=A0document.searchForm.action =3D "mtracker.do";=0A=A0=A0do=
cument.searchForm.submit();=0A=A0}=0A=A0=0A}=0A=0AThanks in antocipation of=
a positive response.=0A=0ARegards=0A=0AAmit=0A=0A
--0-1007767444-1290182245=:89134
Content-Type: text/html; charset=iso-8859-1
Content-Transfer-Encoding: quoted-printable
<html><head><style type=3D"text/css"><!-- DIV {margin:0px;} --></style></he=
ad><body><div style=3D"font-family:times new roman, new york, times, serif;=
font-size:12pt"><DIV>Hi,</DIV>=0A<DIV>I am testing a web application which =
is more of a message tracker. The page I am stuck at present is a search pa=
ge full of Java Script. To avoid JavaScript exceptions I have used HttpUnit=
Options.setScriptingEnabled(false).</DIV>=0A<DIV>My problem is the search b=
utton on which there is onClick event which submits the form via a JavaScri=
pt Fucntion submitForm(); there is no submit button for the search form exc=
ept this search button. Because I have disabled the scripting even if I cal=
l button.doEventScript("onClick") the web page is not moving ahead. please =
can anyone suggest how can I execute this JavaScript Function having HttpUn=
itOptions.setScriptingEnabled set to false.</DIV>=0A<DIV>My code snippet lo=
kks like below:</DIV>=0A<DIV>Button[] buttons =3D form.getButtons();<BR>&nb=
sp; for(int i=3D0; i < buttons.length; i++) {<BR> =
if(buttons[i].getAttribute("value").equalsIgnoreCase("search"))=
{<BR> boolean check =3D engine.createHandler(=
buttons[i]).doEventScript("onClick");<BR> Syst=
em.out.println(check);<BR> response =3D b2bTra=
cker.getCurrentPage();<BR> System.out.println(=
response.getTitle());<BR> <BR> &nbs=
p; }</DIV>=0A<DIV>Submit Form finction looks like below</DIV>=0A=
<DIV>function submitForm()<BR>{<BR> var Submitt =3D "true";<BR> v=
ar tBoxValue =3D document.getElementById("tbox").value;<BR> var tAreaV=
alue =3D document.getElementById("tarea").value;<BR> <BR> if(doc=
ument.getElementById("tbox").style.visibility =3D=3D "visible")<BR> {=
<BR> if( !(tBoxValue =3D=3D "") )<BR> {<BR> &nbs=
p; document.getElementById("searchContent").value =3D document.getElem=
entById("tbox").value;<BR> }<BR> else<BR> =
{<BR> alert("Enter the Search Content in the TextBox");<BR=
> Submitt =3D "false";<BR> document.getEl=
ementById("tbox").focus();<BR> }<BR> }<BR> else if( do=
cument.getElementById("tarea").style.visibility =3D=3D "visible")<BR> =
{<BR> if ( !(tAreaValue =3D=3D "") )<BR> {<BR> &=
nbsp; document.getElementById("searchContent").value =3D
document.getElementById("tarea").value;<BR> }<BR> el=
se<BR> {<BR> alert("Enter the Search Content in=
the TextArea");<BR> Submitt =3D "false";<BR> &=
nbsp;document.getElementById("tarea").focus();<BR> }<BR> }<=
BR> <BR> auditLog =3D document.getElementById("audit").checked;<B=
R> errorLog =3D document.getElementById("error").checked;<BR> deb=
ugLog =3D document.getElementById("debug").checked;<BR> <BR> if(a=
uditLog =3D=3D false && errorLog =3D=3D false && debu=
gLog =3D=3D false)<BR> {<BR> alert("Please Select atleast O=
ne type of LOG");<BR> Submitt =3D "false";<BR> }<BR> e=
lse<BR> {<BR> document.getElementById("searchInAuditLog").v=
alue =3D auditLog;<BR> document.getElementById("searchInErrorLog=
").value =3D errorLog;<BR> document.getElementById("searchInDebu=
gLog").value =3D
debugLog;<BR> }<BR> <BR> startDate =3D document.getElementB=
yId("txtStartDate").value;<BR> endDate =3D document.getElementById("tx=
tEndDate").value;<BR> <BR> if(GetDate(startDate) > GetDate(end=
Date))<BR> {<BR> alert("StartDate shoudn't be greater than =
the EndDate");<BR> Submitt =3D "false";<BR> }<BR> <BR>=
document.getElementById("searchInZipFile").value =3D document.getEleme=
ntById("srchInZipFile").checked;<BR> <BR> <BR> if(Submitt =
=3D=3D "true")<BR> {<BR> document.searchForm.action =3D "mt=
racker.do";<BR> document.searchForm.submit();<BR> }<BR>&nbs=
p;<BR>}</DIV>=0A<DIV> </DIV>=0A<DIV>Thanks in antocipation of a positi=
ve response.</DIV>=0A<DIV> </DIV>=0A<DIV>Regards</DIV>=0A<DIV> </=
DIV>=0A<DIV>Amit</DIV></div><br></body></html>
--0-1007767444-1290182245=:89134--
--===============8007794472716983532==
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
--===============8007794472716983532==
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
--===============8007794472716983532==--