WicketTester how to get html output for component?
Asked Answered
L

1

6

I want to check if a given component has a CSS class set. To do this, I would like to get the HTML output for just that specific component.

WicketTester can provide the HTML output for the entire rendered page. What would be the best approach to get just the Component's HTML/String output?

Limelight answered 4/7, 2013 at 9:36 Comment(0)
H
8

To do this, I would like to get the HTML output for just that specific component.

Instead of making your assertions on the HTML output, you could use TagTester to test the CSS classes like this:

WicketTester tester = new WicketTester(new WicketApplication());
tester.startPage(MyPage.class);
TagTester tagTester = tester.getTagByWicketId("myWicketComponent");
Assert.assertEquals("classA classB", tagTester.getAttribute("class"));

Try if this works for you.

Hanhhank answered 7/7, 2013 at 21:13 Comment(1)
Thanks! I didn't know about the TagTester class. It look promising for my particular problem.Limelight

© 2022 - 2024 — McMap. All rights reserved.