I have an issue to understand how to do it correctly, as I could not find any solution on the net.
I try to test radio selection and click on a download link (bonus would be asserting the downloaded file).
My Code within the Panel is
exportXmlCartForm.add(createDownloadLink("downloadLinkId"));
final Form<Void> exportXmlCartForm = new Form<Void>("xmlCartFileExport");
final RadioGroup<String> group = new RadioGroup<String>("groupFileType", new sharedStringModel);
final Radio<String> radioPartslink = new Radio<String>("fileTypePARTSLINK", Model.of("pl"));
final Radio<String> radioPro = new Radio<String>("fileTypePRO", Model.of("pro"));
final Radio<String> radioCsv = new Radio<String>("fileTypeCSV", Model.of("csv"));
final Radio<String> radioXmlExport = new Radio<String>("fileXmlExport", Model.of("xml"));
group.add(radioPartslink, radioPro, radioCsv, radioXmlExport);
exportXmlCartForm.add(group);
Here is my test so far:
CartDTO cartDTO = new CartDTO();
IModel<CartDTO> cart = Model.of(cartDTO );
PopupPanel confirmPopup = new PopupPanel("1234");
FeedbackPanel feedbackPanel = new FeedbackPanel("12345678");
ShoppingCartFooterPanel p = new ShoppingCartFooterPanel("123", cart, confirmPopup, feedbackPanel);
testPage.setComponentToTest(p);
tester.startPage(testPage);
FormTester ft = tester.newFormTester("123:xmlCartFileExport", false);
ft.select("groupFileType", 3);
Object parstlinkSelected = p.get("xmlCartFileExport:groupFileType").getDefaultModelObject();
tester.clickLink("123:xmlCartFileExport:downloadCart");
What I do not get is
I would appreciate any help.
THX
FormTester.submit()
after making the selection.clickLink(..., false)
to be normal (i.e. non-Ajax) click. Then use tester.getLastResponse().get***()
methods like (getBinaryContent()
and getHeader(String)
) to assert.