To do this, I would like to get HTML output for this particular component.
Instead of making your statements in HTML output, you can use TagTester to test CSS classes as follows:
WicketTester tester = new WicketTester(new WicketApplication()); tester.startPage(MyPage.class); TagTester tagTester = tester.getTagByWicketId("myWicketComponent"); Assert.assertEquals("classA classB", tagTester.getAttribute("class"));
Try it if it works for you.
source share