import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
+import org.openqa.selenium.support.ui.Select;
/**
* Handles the input list inside the interface operation modal.
if (value == null) {
return;
}
- if (value instanceof String || value instanceof Integer || value instanceof Boolean) {
+ if (value instanceof String || value instanceof Integer) {
fillSimpleValue(inputName, String.valueOf(value));
return;
}
+ if (value instanceof Boolean) {
+ fillBooleanValue(inputName, String.valueOf(value));
+ return;
+ }
throw new UnsupportedOperationException("Set input value not yet implemented for value type: " + value.getClass().getName());
}
inputOpt.ifPresent(webElement -> webElement.findElement(simpleInputValueSelector).sendKeys(inputValue));
}
+ private void fillBooleanValue(final String inputName, final String inputValue) {
+ toggleInputExpansion(inputName);
+ final Optional<WebElement> inputOpt = findInput(inputName);
+ assertTrue(inputOpt.isPresent(), String.format("Could not set value for input '%s'. The input was not found.", inputName));
+ final By simpleInputValueSelector = By.xpath(XpathSelector.BOOLEAN_VALUE_INPUT_RELATIVE_FROM_INPUT_INFO.getXPath());
+ final WebElement booleanDropdownWebElement = inputOpt.get().findElement(simpleInputValueSelector);
+ new Select(booleanDropdownWebElement).selectByValue(inputValue);
+ }
+
@AllArgsConstructor
private enum XpathSelector {
WRAPPING_ELEMENT("//div[@class='input-tree']"),
INPUT_LABEL("label[@class='input-label']"),
INPUT_TYPE("em[@data-tests-id='input-type']"),
SIMPLE_VALUE_INPUT_RELATIVE_FROM_INPUT_INFO("..//li[@class='input-value']/input"),
+ BOOLEAN_VALUE_INPUT_RELATIVE_FROM_INPUT_INFO("..//li[@class='input-value']/select"),
EXPAND_ICON("em[contains(concat(' ',normalize-space(@class),' '),' round-expand-icon ')]"),
DELETE_ICON("span[contains(concat(' ',normalize-space(@class),' '),' delete-btn ')]");