I found a way to do this with HtmlUnit:
StringWebResponse resp = new StringWebResponse(html, new URL("
http://localhost"));
WebClient client = new WebClient();
HtmlPage page = HTMLParser.parseHtml(resp, client.getCurrentWindow());
Now just need a way to wrap it with JWebUnit somehow?
I am writing unit tests for GSP pages in Grails framework. Rendering the
GSP pages in isolation is supported by the Grails unit testing support. As
outcome I have the html page as String, so I need to have some elegant way
to verify e.g. elements and contents on the page. JWebUnit seems to have a
good set of matchers available.
On Mon, Sep 8, 2014 at 2:59 AM, Jevon Wright <je...@jevon.org> wrote:
> I don't think there's any way to do this with JWebUnit/HtmlUnit (most web
> pages load additional resources - JS, CSS etc) - perhaps you could look at
> using a web server component like Jetty (which we use for our tests
> ourselves) to host the generated HTML, which you can then connect to to
> test.
>
> Cheers
> Jevon
>
>
> On Sat, Sep 6, 2014 at 11:17 PM, raipe - <raipe.trashm...@gmail.com>
> wrote:
>
>> How to use the jWebUnit to verify elements in a page created from
>> String/byte[]?
>>
>> This is needed to unit test views rendered from the application. Note:
>> the application is not running but view is rendered using the unit testing
>> features of the framework.
>>
>> So what I want is to do jWebUnit testing for a page created from string.
>>
>>
>> ------------------------------------------------------------------------------
>> Slashdot TV.
>> Video for Nerds. Stuff that matters.
>> http://tv.slashdot.org/
>> _______________________________________________
>> JWebUnit-users mailing list
>> JWebUnit-users@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/jwebunit-users
>>
>>
>
>
> ------------------------------------------------------------------------------
> Want excitement?
> Manually upgrade your production database.
> When you want reliability, choose Perforce
> Perforce version control. Predictably reliable.
>
> http://pubads.g.doubleclick.net/gampad/clk?id=157508191&iu=/4140/ostg.clktrk
> _______________________________________________
> JWebUnit-users mailing list
> JWebUnit-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/jwebunit-users
>
>
------------------------------------------------------------------------------
Want excitement?
Manually upgrade your production database.
When you want reliability, choose Perforce
Perforce version control. Predictably reliable.
http://pubads.g.doubleclick.net/gampad/clk?id=157508191&iu=/4140/ostg.clktrk
_______________________________________________
JWebUnit-users mailing list
JWebUnit-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jwebunit-users