Hi,
I have been testing one site, which has used javascript for navigation and I do
not have control over its source code.
For some of the pages i get this error:
Test step clickLink (/root/projects/canoo/webtest_sample/modules/sample.xml:11:
) named "Click link: JSP page" failed with message "Step[clickLink "Click
link: JSP page" (4/7)]: Script error loading page executing webtest at:
clickLink TypeError: pageLoaded is not a function, it is null. (event for
HtmlBody[<body bgcolor="white" onload="pageLoaded();">]#1)
Source code:
function () {
[native code, arity=0]
}
"
This happens because the javascript functions are declared/defined after html
tag, i tried with a sample app:
Sample Code:
<html>
<head>
<title>Sample Application JSP Page</title>
</head>
<body bgcolor=white onLoad="pageLoaded();">
<form name="sampleForm" method="get" action="hello" >
Some html code.....
<a href="index.html" onclick="nextButtonClicked(); return false;"
class="nextbutton" id="next">Next</a>
</td
</table>
</form>
</body>
</html>
// JS functions after the html tag
<script type="text/javascript">
function nextButtonClicked()
{
document.sampleForm.submit();
return false;
}
function pageLoaded()
{
return false;
}
</script>
If I move the JS Code before html tag as:
<html>
<head>
<title>Sample Application JSP Page</title>
</head>
<body bgcolor=white onLoad="pageLoaded();">
<form name="sampleForm" method="get" action="hello" >
Some html code.....
<a href="index.html" onclick="nextButtonClicked(); return false;"
class="nextbutton" id="next">Next</a>
</td
</table>
</form>
</body>
// JS functions before the html tag
<script type="text/javascript">
function nextButtonClicked()
{
document.sampleForm.submit();
return false;
}
function pageLoaded()
{
return false;
}
</script>
</html>
It works fine now, but as i said I CANNOT change the site codebase, how i can
workaround this problem. Will changing the browser version for htmlunit help,
if yes how can i change it.
Please help or give some pointers
Best Regards,
amit
____________________________________________________________________________________
Have a burning question?
Go to www.Answers.yahoo.com and get answers from real people who know.