I'm also printing out the value of the test parameter both before and after I attempt to click the Edit button using button.click(). In both cases the Test parameter is empty. If I just run through the form in the browser and do a View Source when I hit this page I see the value that should be posted to the form on the page.
Is anyone aware of anything else I need to do in httpUnit to get the value populated so that it is posted when the form is submitted?
I would appreciate any information anyone has regarding this issue. Thanks.
Rebekah Pfaff
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I can't seem to be able to get the onClick() method on the page to fire using httpUnit.
Here is some sample code of what I'm trying to do:
Here is a snippet of code from the jsp page:
<HTML>
<HEAD>
<script language=javascript>
<!--
function testt(test) {
document.forms[0].test.value = test;
return;
}
//-->
</script>
</HEAD>
</HTML>
Ok...I accidently submitted the question before I intended to...sorry about that.
Anyway, here are the relavent code snippets:
<HTML>
<HEAD>
<script language=javascript>
<!--
function setTest(test) {
document.forms[0].test.value = test;
return;
}
//-->
</script>
</HEAD>
<BODY>
<TABLE>
<TR>
<TD>
<form name="testform" method="post" action="ProcessRequest.jsp">
<input type="hidden" name="test" value="">
</form>
<input type="submit" name="Edit" value="Edit" onClick="setTest(1)">
</TD>
</TR>
</TABLE>
</BODY>
</HTML>
Here is the test code from httpUnit:
if(actions[i].equalsIgnoreCase("edit")){
WebResponse response = session.getCurrentPage();
HttpUnitOptions.setScriptingEnabled( true );
Button[] formButtons = form.getButtons();
int j = 0;
while(!formButtons[j].getName().equalsIgnoreCase("edit") && j<formButtons.length){j++;} //Find the edit button
if(j<formButtons.length){
formButtons[j].click(); //Click the button
}
response = session.getCurrentPage();
}
I'm also printing out the value of the test parameter both before and after I attempt to click the Edit button using button.click(). In both cases the Test parameter is empty. If I just run through the form in the browser and do a View Source when I hit this page I see the value that should be posted to the form on the page.
Is anyone aware of anything else I need to do in httpUnit to get the value populated so that it is posted when the form is submitted?
I would appreciate any information anyone has regarding this issue. Thanks.
Rebekah Pfaff