wicket-tester

How do I query the text of an element (Component) using WicketTester?

烈酒焚心 提交于 2019-12-11 10:22:57
问题 Rather than specifying the id-path for components to click in WicketTester I'd like to find the link with a specific text. I can use MarkupContainer.visitChildren to run through the tree, but can I get the actual rendered component text for each leaf - something like .innerHTML ? 回答1: Yes, see TagTester. It is part of WicketTester family. 来源: https://stackoverflow.com/questions/6413022/how-do-i-query-the-text-of-an-element-component-using-wickettester

How to unit test a custom Wicket component

浪子不回头ぞ 提交于 2019-12-10 16:28:58
问题 Given this really simple Wicket component: public class ProductImage extends WebComponent { public ProductImage(String id, Product p) { super(id, new Model(p)); add(new AttributeModifier("src", true, new Model(p.getImage()))); } } How to unit test it using WicketTester? Do I need a page? 回答1: I haven't actually done that (I've only tested panels), but startComponent() seems to be the way to do it. Something like this: Product product = new Product(/* initialize product here */); ProductImage