views:

670

answers:

1

I am trying to wrap my head around canoo webtest

I setup a simple groovy webtest. I have even made and run the xml equivalent and I get the same error when it tries to encode the url.

I get an error when I use a context root. I don't get an error when I just use the url with out the context root. ie."http://somesite.com"

Other than there being extra letters and such there is also another slash but apparently the stupid byte code decoder could handle a slashes with the http:// part... Why not something as simple as a directory

I would think webtest would be able to handle something as simple as a directory within a site or a context root or at least detecting and encoding the data correctly. Loading any type of url would be of paramount importance if you were writing an application called "Web"test..

invoke(url: "http://somesite.com/CONTEXTRoot", description: "Load dev java site")
verifyTitle("Title to check")

or

<?xml version="1.0" ?>
<!DOCTYPE project SYSTEM "../dtd/Project.dtd">
<project default="test">
    <target name="test">
     <webtest name="check login and welcome page load and work">
      <invoke description="Go to dev site" 
        url="http://devsite.com/CONTEXTRoot/" />    
      <clickButton label="Enter Application" />
     </webtest>
    </target>
</project>

Stacktrace:

E:\canoo\WebSiteFunctionalTests\tests\WebSiteWebTest.xml:11: Unexpected exception caught: sun.io.MalformedInputException
at com.canoo.webtest.steps.StepUtil.handleException(StepUtil.java:120)
at com.canoo.webtest.steps.Step.handleException(Step.java:379)
at com.canoo.webtest.steps.Step.execute(Step.java:110)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
    ...
  Caused by: sun.io.MalformedInputException
    at sun.io.ByteToCharUTF8.convert(ByteToCharUTF8.java:262)
    at sun.nio.cs.StreamDecoder$ConverterSD.convertInto(StreamDecoder.java:314)
    at sun.nio.cs.StreamDecoder$ConverterSD.implRead(StreamDecoder.java:364)
    at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:250)
    at java.io.InputStreamReader.read(InputStreamReader.java:212)
    at org.cyberneko.html.HTMLScanner.load(HTMLScanner.java:1166)
    at org.cyberneko.html.HTMLScanner.read(HTMLScanner.java:1127)
    at org.cyberneko.html.HTMLScanner$ContentScanner.scan(HTMLScanner.java:1913)
    at org.cyberneko.html.HTMLScanner.scanDocument(HTMLScanner.java:893)
    at org.cyberneko.html.HTMLConfiguration.parse(HTMLConfiguration.java:495)
    at org.cyberneko.html.HTMLConfiguration.parse(HTMLConfiguration.java:448)
    at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
    at com.gargoylesoftware.htmlunit.html.HTMLParser$HtmlUnitDOMBuilder.parse(HTMLParser.java:680)
    at com.gargoylesoftware.htmlunit.html.HTMLParser.parse(HTMLParser.java:240)
    at com.gargoylesoftware.htmlunit.DefaultPageCreator.createHtmlPage(DefaultPageCreator.java:127)
    at com.gargoylesoftware.htmlunit.DefaultPageCreator.createPage(DefaultPageCreator.java:101)
    at com.canoo.webtest.engine.Configuration$2.createPage(Configuration.java:655)
A: 

I got it to work on the invoke when I changed the meta and page tag in my jsp

from

<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
<META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">

to

<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<META http-equiv="Content-Type" content="text/html; charset=UTF-8">

I submitted a JIRA bug about this since the error only occurs during an invoke and not on form submits and link clicks.

mugafuga