/** * Must not set submitOnChange on a WToggleButton. If you need a button which submits the form use * {@link com.github.bordertech.wcomponents.WButton}. * @param submitOnChange not used */ @Override public void setSubmitOnChange(final boolean submitOnChange) { throw new SystemException("Cannot set submitOnChange on a toggle button."); }
/** * Do not allow defaultSubmitButton on a WToggleButton. * @param defaultSubmitButton not used */ @Override public void setDefaultSubmitButton(final WButton defaultSubmitButton) { throw new SystemException("Cannot set default submit button on a toggle button."); }
/** * {@inheritDoc}. */ @Override public DesiredCapabilities getDefaultDriverCapabilities() { throw new SystemException("Capabilities not supported by ParameterizedWebDriverType."); }
/** * @return the project version of WComponents. */ public static String getProjectVersion() { String version = ConfigurationProperties.getProjectVersion(); if (version == null) { throw new SystemException("The project version parameter has not been defined."); } return version; }
/** * Ensures that the repeater has been correctly configured. A SystemException will be thrown if the repeater is not * configured correctly. */ private void assertConfigured() { if (getRepeatRoot() == null) { throw new SystemException( "WRepeater not configured correctly. No repeated component supplied."); } }
/** * {@inheritDoc} */ @Override public Object createTest() throws Exception { Object test = super.createTest(); if (!(test instanceof WComponentSeleniumTestCase)) { throw new SystemException("MultiBrowserRunner cannot be used for test that does not extend WComponentSeleniumTestCase." + " test class: " + test.getClass().getName()); } ((WComponentSeleniumTestCase) test).setDriver(driverType, driverId); return test; }
/** * {@inheritDoc} */ @Override protected UIContext createUIContext() { if (getTargetComponentId() != null) { throw new SystemException("AJAX request for a session with no context set"); } return super.createUIContext(); }
/** * @return the WebElement representing the 'available' options list. */ public WebElement getAvailableList() { if (isReadOnly()) { throw new SystemException("Cannot get available list from a read-only WMultiSelectPair"); } return findElementImmediate(By.className("wc_msp_av")); }
/** * Gets the dropdowns in the WMultiDropdown. There will be one per selected option. * @return the selection dropdowns in the WMultiDropdown. */ public List<WebElement> getDropdowns() { if (isReadOnly()) { throw new SystemException("Cannot get selection lists from a read-only WMultiDropdown"); } return findElementsImmediate(By.tagName("select")); }
/** * @return the WebElement representing the 'selected' options list. */ public WebElement getSelectedList() { if (isReadOnly()) { throw new SystemException("Cannot get selected list from a read-only WMultiSelectPair"); } return findElementImmediate(By.className("wc_msp_chos")); }
/** * FInd a button based on a CSS selector. * * @param selector the CSS selector to use * @return a WebElement representing the button. */ private WebElement getButton(final String selector) { if (isReadOnly()) { throw new SystemException("Cannot get buttons from a read-only WMultiSelectPair"); } return findElementImmediate(By.cssSelector("button" + selector)); }
/** * @return the button to add an option to the WMultiDropdown */ public WebElement getAddButton() { if (isReadOnly()) { throw new SystemException("Cannot get add button from a read-only WMultiDropdown"); } return findElementImmediate(By.tagName("button")); }
/** * Get the interactive HTML control with a given label. Only applies to components in an interactive state. * * @param labelText the text of the label for the option we are after * @return the active HTML element, if any */ public WebElement getInput(final String labelText) { if (isReadOnly()) { throw new SystemException("Component in a read-only state has no interactive controls."); } return findElementImmediate(new ByLabel(labelText, false, true)); }
/** * @return the WebElement representing the 'available' options dropdown. */ public WebElement getFirstDropdown() { if (isReadOnly()) { throw new SystemException("Cannot get active list from a read-only WMultiDropdown"); } return findElementImmediate(By.tagName("select")); }
/** * Set a new selection in the first dropdown in a WMultiDropdown using visible option text. Convenient for setting a single selection. * @param toText the visible text of the option to select */ public void switchFirstOption(final String toText) { if (isReadOnly()) { throw new SystemException("Cannot switch selection from a read-only WMultiDropdown"); } WebElement dropdown = getFirstDropdown(); Select se = new Select(dropdown); se.selectByVisibleText(toText); }
/** * Get the input control belonging to a particular option in the group. * * @param option the option we are trying to interact with * @return the input control of that option */ public WebElement getInput(final WebElement option) { if (isReadOnly()) { throw new SystemException("Components in a read-only state have no inputs."); } return SeleniumWComponentsUtil.findElementImmediateForElement(option, By.tagName(getOptionTag())); }
@Test public void testHandleErrorCustom() throws IOException { MyContainerHelper helper = new MyContainerHelper(); SystemException error = new SystemException("custom"); helper.handleError(error); String output = helper.stringWriter.toString(); Assert.assertTrue("Should contain transformed XML", output.contains(TransformXMLTestHelper.EXPECTED)); }
@Test public void testHandleErrorDefault() throws IOException { MyContainerHelper helper = new MyContainerHelper(); SystemException error = new SystemException("test"); helper.handleError(error); String output = helper.stringWriter.toString(); Assert.assertTrue("Should contain default error message", output.contains("currently unavailable")); }
/** * Get the radio button at a given option index. Only applies to WRadioButtonSelect in an interactive state. * * @param idx the option's index * @return a HTML input element in the radio button state. */ public WebElement getRadioButton(final int idx) { if (isReadOnly()) { throw new SystemException("WRadioButtonSelect in a read-only state has no radio buttons."); } WebElement option = getOption(idx); By by = By.tagName(getOptionTag()); return SeleniumWComponentsUtil.findElementImmediateForElement(option, by); }
/** * Select an option using its visible text. * @param optionText the text of the option to select */ public void select(final String optionText) { if (isReadOnly()) { throw new SystemException("Cannot select from a read-only WMultiDropdown"); } clickButton(getAddButton(), true); Select se = new Select(getFirstDropdown()); se.selectByVisibleText(optionText); }