Hi Everyone,

Marc, thanks for taking time to answer !

I have tried to exchange the HtmlUnit-2.2.jar by htmlunit-2.3-SNAPSHOT.jar,
but it didn't work. It even can't finish the first invoke step. Then I add
the ThrowExceptionOnScriptErro  config lins into the Script. the record
shows all right,but the page can't jump to the next one, ,the test didn't
went on.I think it must be the problem of improper use of JS in the html.
What's funy is that  I browse the page by Chrome by accident, the JavaScript
Consosle function report the same "undifined submit" error.
Now the developer of this page is working on fixing this bug.

Any opinion anyone can provide would be greatly appreciated.

the source code of the page:

<link rel="stylesheet" href="/Asahi/css/common.css" type="text/css"/>
 <base href="http://192.168.90.79:8080/Asahi/loginForward.jsp";>
<html>
<head>
<title>Editor Database</title>
<script language="javascript" src="javascript/common.js"></script>
<script language="javascript">
/*function execute()
{
var sFeaturs = "height=" + (screen.availHeight - 60) +
   ",width=" + (screen.availWidth - 10) +
   ",scrollbars=yes,resizable=yes,location=yes,menubar=yes, toolbar=no,
status=yes, top=0, left=0";

var login_id = document.getElementById("login_id").value;
var login_pwd =document.getElementById("login_pwd").value ;
 var url =
"login.do?method=login&login_id="+login_id+"&login_pwd="+login_pwd;
 var work = window.open(url, "win", sFeaturs);
 window.opener = "temp";
window.close();
}*/

function formSubmit()
{
  var formObj = document.form1;
  doSubmit(formObj);
}

function confirmClick()
{
  formSubmit();
}
</script>
</head>
<body style="background-color: #FFFFFF">
<form name="userForm" method="post"
action="/Asahi/login.do;jsessionid=0949F78A6D95BF48EB7ADEAD7422AD2F?method=login"
id="form1">
<input type="hidden" name="btnId" value="all"  >
<table width="100%" height="100%" border="0" cellpadding="0"

cellspacing="0">
<tr height="100%">
<td width="100%" height="400" align="center" valign="middle">
<table width="402" height="238" border="0" cellpadding="0"

cellspacing="1">
<tr>
</tr>
<tr>
<td width="450" height="126" bgcolor="#FFFFFF">
<table width="402" height="121" border="0" cellspacing="10"

style="filter:progid:DXImageTransform.microsoft.gradient(gradientType=0,startColorStr=#ffffff,endColorStr=#FF9900)">
<tr>
<td width="100" align="right">UserID</td>
<td align="left"><input id="login_id" name="login_id" type="text"

style="width: 126" value="asahi"/></td>
</tr>
<tr>
<td width="100" align="right">Password</td>
<td align="left"><input id ="login_pwd" name="login_pwd" type="password"

style="width: 126" value="asahi"/></td>
</tr>
<tr>
<td align="right">&nbsp;</td>
<td align="center">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <input

type="button" value="login" name="BtnOk"

onClick="confirmClick();"></td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</form>
</body>
</html>
<script language="javascript">
document.getElementById("login_id").focus();
function handle()
{
if(event.keyCode==13)
{
//confirmClick();
confirmClick();
}
}
document.onkeydown=handle;
</script>

--__--__--

Message: 8
Date: Tue, 02 Sep 2008 14:03:30 +0200
From: Marc Guillemot <[EMAIL PROTECTED]>
To: [email protected]
Subject: Re: [Webtest] "Cannot call method "submit" of undefined" Error when
 test a login page
Reply-To: [email protected]
Reply-To: Marc Guillemot <[EMAIL PROTECTED]>

Hi,

if your page really doesn't have any JS error then it means that your JS
code is not supported by HtmlUnit, or more exactly by the HtmlUnit
version you're using. If you use a recent build of WebTest, you will
have HtmlUnit-2.2 shipped with it and if the error still exist, you can
probably try to replace the HtmlUnit-2.2.jar by a snapshot of
HtmlUnit-2.3. If the problem persists, then I'm interested if you could
provide a minimal testcase allowing to reproduce the problem and report
it to the HtmlUnit project.

As workaround, you can configure your webtest to ignore JS errors (but
then you won't detect JS errors, even "real" ones):
<config>
 <option name="ThrowExceptionOnScriptError" value="false"/>
</config>

Cheers,
Marc.
--
Blog: http://mguillem.wordpress.com

[EMAIL PROTECTED] wrote:
> Hi, Everyone
>
> I wrote an easy testcase for a login page. Just invoke the url ,then
> find the button by xpath and click it.The form will submint login datas
> and goto another page.
> the ID and pass word is write in the html, so no need to set input.
> I'm srue the xpath is right , it gets wrong at the last step.I don't
> know is it Script problem or the JS in the page have any bug. and  I
> don't think it's the method "submit" is the real point.
>
> It will be greatly appreciate if anyone could tell me the reason or your
> opinion.
> Please DO reply me if you had met the same problem.
>
> thanks
>
> * The error message:*
>
> JavaScript error loading page http://192.xxx.xx.xx:8080/Ash/: TypeError:
> Cannot call method "submit" of undefined (script in
> http://192.xxxxx.xx:8080/Ash/ from (16, 31) to (0, 0)#37)
>
> *My Script:*
>
> <?xml version="1.0"?>
> <!DOCTYPE project SYSTEM "../dtd/Project.dtd">
> <project default="ifdmsLogintest">
>
>     <target name="ifdmsLogintest">
>
>         <webtest name="check the login founction">
>             <invoke url="http://192.xxx.xx.xx:8080/Ash/"; description="Go
> to asahi login"/>
>             <clickButton xpath="//[EMAIL PROTECTED] = 'button']"
> description="login" />
>
>         </webtest>
>     </target>
> </project>
>
>

Reply via email to