Karate (Thymeleaf -> SAXParser) prints "Fatal Error" when encountering valid HTML5
See original GitHub issueI am attempting to use Karate to authenticate with our service via an OAuth2 authorization code grant. During the process, my test needs to fetch (and parse, using JSoup in a Java interop) our service’s scope approval web page. This page is valid HTML5 (hopefully), containing unclosed <link>
and <meta>
tags.
As far as I can tell, karate attempts to parse that page through thymeleaf, which, in turn seems to attempt to use a SAXParser to process. That results in an error message “Fatal Error” in the logs (although the test then continues and succeeds).
I am attaching a trivial feature file html5-fetch.feature.txt to fetch from a stub from a web site of mine.
Unfortunately, I seem to be unable to produce an English error message; the German equivalent is
[Fatal Error] :7:5: Elementtyp "link" muss mit dem entsprechenden Endtag "</link>" beendet werden.
13:24:03.947 [main] WARN com.intuit.karate - auto-conversion of response failed: org.xml.sax.SAXParseException; lineNumber: 7; columnNumber: 5; Elementtyp "link" muss mit dem entsprechenden Endtag "</link>" beendet werden.
(seems to translate to org.xml.sax.SAXParseException: Element type "link" must be terminated by a matching end tag "</link>"
)
I would prefer not having “Fatal Errors” in my test logs, even when they succeed. It does not seem to be a good idea to attempt to parse responses as xml, unless the content type is xml.
I am fine if you regard this topic as a non-issue 😃
Issue Analytics
- State:
- Created 2 years ago
- Comments:8 (6 by maintainers)
@ptrthomas Perfect! Works for me, fixes both the sample request as well as my production code.
Thanks for your hint for the karate.extract() function. Probably a valuable solution for lots of cases. However, in my case I need to collect all “name” attributes of all html entities with a certain “class” attribute. That’s 3 lines of well readable code using Java, but would be hell of a regex using the “extract” function, I suppose.
The diff looks straight forward and really sensible to me. However, I do understand that this might be breaking for some folks.
Thanks again!
Please re-open. See PR https://github.com/intuit/karate/pull/1705