use of com.github.bordertech.wcomponents.util.SystemException in project wcomponents by BorderTech.
the class AbstractCompare_Test method testGetTriggerValueInvalidTrigger.
@Test
public void testGetTriggerValueInvalidTrigger() {
SubordinateTrigger trigger = new MyInvalidTrigger();
AbstractCompare compare = new MyCompare(trigger, null);
try {
compare.execute();
Assert.fail("Should have thrown exception for invalid subordinate trigger.");
} catch (SystemException e) {
Assert.assertNotNull("Exception for invalid subordinate trigger should have a message", e.getMessage());
}
}
use of com.github.bordertech.wcomponents.util.SystemException in project wcomponents by BorderTech.
the class SeleniumWComponentsWebDriver method findButton.
/**
* @param buttonTextOrTitle the text expected in the button
* @param searchAttributes if {@code true} then also look at labelling attributes title and aria-label.
* @return a WebElement representing a button described by the required text.
*/
public WebElement findButton(final String buttonTextOrTitle, final boolean searchAttributes) {
if (Util.empty(buttonTextOrTitle)) {
throw new IllegalArgumentException("Cannot find a button with no text");
}
List<WebElement> buttons = findElements(By.tagName("button"));
for (WebElement button : buttons) {
String text = button.getText();
if (buttonTextOrTitle.equalsIgnoreCase(text)) {
return button;
}
if (searchAttributes) {
text = button.getAttribute("title");
if (buttonTextOrTitle.equalsIgnoreCase(text)) {
return button;
}
text = button.getAttribute("aria-label");
if (buttonTextOrTitle.equalsIgnoreCase(text)) {
return button;
}
}
}
throw new SystemException("No button containing required text.");
}
use of com.github.bordertech.wcomponents.util.SystemException in project wcomponents by BorderTech.
the class SeleniumWComponentsWebDriverFactory method createBackingDriver.
/**
* Create a WebDriver implementation from a String class name.
*
* @param backingDriverClass the WebDriver implementation class.
* @return the WebDriver implementation.
*/
public static WebDriver createBackingDriver(final String backingDriverClass) {
if (StringUtils.isBlank(backingDriverClass)) {
throw new IllegalArgumentException("backingDriverClass must not be blank");
}
try {
Class clazz = Class.forName(backingDriverClass);
if (!WebDriver.class.isAssignableFrom(clazz)) {
throw new SystemException("backingDriverClass does not implement WebDriver inteface. backingDriverClass=[" + backingDriverClass + "]");
}
Class<WebDriver> driverClass = (Class<WebDriver>) clazz;
WebDriver backingDriver = (WebDriver) driverClass.newInstance();
return backingDriver;
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException ex) {
throw new SystemException("Unable to create backingDriverClass by classname String. backingDriverClass=[" + backingDriverClass + "]", ex);
}
}
use of com.github.bordertech.wcomponents.util.SystemException in project wcomponents by BorderTech.
the class SeleniumCheckableGroupInputWebElement method getOption.
/**
* Find an option with a particular label.
*
* @param labelText the text content of the option's label
* @return the option
*/
public WebElement getOption(final String labelText) {
List<WebElement> options = getOptions();
if (CollectionUtils.isEmpty(options)) {
throw new SystemException("No options available");
}
if (isReadOnly()) {
for (WebElement o : options) {
if (labelText.equalsIgnoreCase(o.getText())) {
return o;
}
}
throw new IllegalArgumentException("Could not find option identified by " + labelText);
}
SeleniumWComponentWebElement input = findElementImmediate(new ByLabel(labelText, false, true));
return input.findElementImmediate(By.xpath(".."));
}
use of com.github.bordertech.wcomponents.util.SystemException in project wcomponents by BorderTech.
the class SeleniumWMultiDropdownWebElement method getDropdown.
/**
* @param optionText the text of the selected option
* @return a representation of the select list with selection equal to the selected option text
*/
public WebElement getDropdown(final String optionText) {
if (isReadOnly()) {
throw new SystemException("Cannot get option lists from a read-only WMultiDropdown");
}
if (optionText == null) {
throw new IllegalArgumentException("Cannot get a reference to the selected option list without the option text");
}
List<WebElement> dropdowns = getDropdowns();
if (dropdowns.isEmpty()) {
// theoretically this is impossible
throw new SystemException("Cannot find any selected lists");
}
Select se;
WebElement option;
for (WebElement dropdown : dropdowns) {
se = new Select(dropdown);
option = se.getFirstSelectedOption();
if (optionText.equalsIgnoreCase(option.getText())) {
return dropdown;
}
}
throw new SystemException("Cannot get a list for that option text");
}
Aggregations