Your html code is malformed (content after the </html>). To get better messages from the parser, WebTest sets

WebClient.setIgnoreOutsideContent(true);

I suppose that you can do following as first step of your <webtest>

<groovy>
step.context.webClient.ignoreOutsideContent = false
</groovy>

Marc.


amit shrivas wrote:
I tried the same sample application with htmlunit as:

public class HtmlUnitMain {
    public static void main(String[] args) {
final WebClient webClient = new WebClient(BrowserVersion.NETSCAPE_4_7_9);
        URL url;
        try {
            url = new URL("http://localhost:8180/sample/hello.jsp";);
            final HtmlPage page = (HtmlPage)webClient.getPage(url);
System.out.println(webClient.getBrowserVersion()); System.out.println(page.getTitleText());
            HtmlAnchor anchor = page.getAnchorByName("next");
            HtmlPage jspPage = (HtmlPage)anchor.click();
            System.out.println(jspPage.getTitleText());
}

It works fine, Can anyone help me in understanding why this does not work in Webtest Canoo.

I am stuck from past 2 - 3 days in this, it will be great help

thanks in advance,
amit

----- Original Message ----
From: amit shrivas <[EMAIL PROTECTED]>
To: [email protected]
Sent: Wednesday, February 14, 2007 11:20:06 PM
Subject: Regarding javascript error not able to proceed....

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

------------------------------------------------------------------------
Need a quick answer? Get one in minutes from people who know. Ask your question on Yahoo! Answers <http://answers.yahoo.com/;_ylc=X3oDMTFvbGNhMGE3BF9TAzM5NjU0NTEwOARfcwMzOTY1NDUxMDMEc2VjA21haWxfdGFnbGluZQRzbGsDbWFpbF90YWcx>.


------------------------------------------------------------------------
Never miss an email again!
Yahoo! Toolbar <http://us.rd.yahoo.com/evt=49938/*http://tools.search.yahoo.com/toolbar/features/mail/> alerts you the instant new Mail arrives. Check it out. < http://us.rd.yahoo.com/evt=49937/*http://tools.search.yahoo.com/toolbar/features/mail/>

_______________________________________________
WebTest mailing list
[email protected]
http://lists.canoo.com/mailman/listinfo/webtest

Reply via email to