diff --git a/src/main/java/aquality/selenium/elements/ComboBox.java b/src/main/java/aquality/selenium/elements/ComboBox.java index 39459ec..3b8e900 100644 --- a/src/main/java/aquality/selenium/elements/ComboBox.java +++ b/src/main/java/aquality/selenium/elements/ComboBox.java @@ -49,7 +49,7 @@ public void clickAndSelectByText(String value) { @Override public void selectByContainingText(String text) { logElementAction("loc.combobox.select.by.text", text); - selectOptionThatContains(WebElement::getText, + applyFunctionToOptionsThatContain(WebElement::getText, Select::selectByVisibleText, text); } @@ -57,12 +57,12 @@ public void selectByContainingText(String text) { @Override public void selectByContainingValue(String value) { logElementAction(LOG_SELECTING_VALUE, value); - selectOptionThatContains(element -> element.getAttribute(Attributes.VALUE.toString()), + applyFunctionToOptionsThatContain(element -> element.getAttribute(Attributes.VALUE.toString()), Select::selectByValue, value); } - private void selectOptionThatContains(Function getValueFunc, BiConsumer selectFunc, String value){ + protected void applyFunctionToOptionsThatContain(Function getValueFunc, BiConsumer selectFunc, String value){ doWithRetry(() -> { Select select = new Select(getElement()); List elements = select.getOptions(); @@ -77,7 +77,7 @@ private void selectOptionThatContains(Function getValueFunc, } if (!isSelected){ throw new InvalidElementStateException(String.format(getLocalizationManager().getLocalizedMessage( - "loc.combobox.impossible.to.select.contain.value.or.text"), value, getName())); + "loc.combobox.impossible.to.find.option.contain.value.or.text"), value, getName())); } }); } diff --git a/src/main/java/aquality/selenium/elements/ElementFactory.java b/src/main/java/aquality/selenium/elements/ElementFactory.java index ed99699..544139f 100644 --- a/src/main/java/aquality/selenium/elements/ElementFactory.java +++ b/src/main/java/aquality/selenium/elements/ElementFactory.java @@ -45,6 +45,7 @@ protected Map getSelectedValues() { + logElementAction("loc.combobox.getting.selected.value"); + return collectSelectedOptions(option -> option.getAttribute(Attributes.VALUE.toString()), "value"); + } + + @Override + public List getSelectedTexts() { + logElementAction("loc.combobox.getting.selected.text"); + return collectSelectedOptions(WebElement::getText, "text"); + } + + private List collectSelectedOptions(Function valueGetter, String valueType) { + List texts = doWithRetry(() -> + new Select(getElement()).getAllSelectedOptions() + .stream() + .map(valueGetter) + .collect(Collectors.toList())); + String logValue = texts.stream().map(value -> String.format("'%s'", value)).collect(Collectors.joining(", ")); + logElementAction(String.format("loc.combobox.selected.%s", valueType), logValue); + return texts; + } + + @Override + public void selectAll() { + logElementAction("loc.multichoicebox.select.all"); + applyFunctionToOptionsThatContain(element -> element.getAttribute(Attributes.VALUE.toString()), + Select::selectByValue, + StringUtils.EMPTY); + } + + @Override + public void deselectAll() { + logElementAction("loc.multichoicebox.deselect.all"); + doWithRetry(() -> new Select(getElement()).deselectAll()); + } + + @Override + public void deselectByIndex(int index) { + logElementAction(LOG_DESELECTING_VALUE, String.format("#%s", index)); + doWithRetry(() -> new Select(getElement()).deselectByIndex(index)); + } + + @Override + public void deselectByValue(String value) { + logElementAction(LOG_DESELECTING_VALUE, value); + doWithRetry(() -> new Select(getElement()).deselectByValue(value)); + } + + @Override + public void deselectByContainingValue(String value) { + logElementAction(LOG_DESELECTING_VALUE, value); + applyFunctionToOptionsThatContain(element -> element.getAttribute(Attributes.VALUE.toString()), + Select::deselectByValue, + value); + } + + @Override + public void deselectByText(String text) { + logElementAction("loc.multichoicebox.deselect.by.text", text); + doWithRetry(() -> new Select(getElement()).deselectByVisibleText(text)); + } + + @Override + public void deselectByContainingText(String text) { + logElementAction("loc.multichoicebox.deselect.by.text", text); + applyFunctionToOptionsThatContain(WebElement::getText, + Select::deselectByVisibleText, + text); + } +} diff --git a/src/main/java/aquality/selenium/elements/interfaces/IElementFactory.java b/src/main/java/aquality/selenium/elements/interfaces/IElementFactory.java index 13cd99a..d743786 100644 --- a/src/main/java/aquality/selenium/elements/interfaces/IElementFactory.java +++ b/src/main/java/aquality/selenium/elements/interfaces/IElementFactory.java @@ -80,6 +80,29 @@ default IComboBox getComboBox(By locator, String name, ElementState state) { return get(ElementType.COMBOBOX, locator, name, state); } + /** + * Creates element that implements IMultiChoiceBox interface. + * + * @param locator Element locator + * @param name Element name + * @return Instance of element that implements IMultiChoiceBox interface + */ + default IMultiChoiceBox getMultiChoiceBox(By locator, String name) { + return getMultiChoiceBox(locator, name, ElementState.DISPLAYED); + } + + /** + * Creates element that implements IMultiChoiceBox interface. + * + * @param locator Element locator + * @param name Element name + * @param state Element state + * @return Instance of element that implements IMultiChoiceBox interface + */ + default IMultiChoiceBox getMultiChoiceBox(By locator, String name, ElementState state) { + return get(ElementType.MULTICHOICEBOX, locator, name, state); + } + /** * Creates element that implements ILabel interface. * diff --git a/src/main/java/aquality/selenium/elements/interfaces/IMultiChoiceBox.java b/src/main/java/aquality/selenium/elements/interfaces/IMultiChoiceBox.java new file mode 100644 index 0000000..f3ee29a --- /dev/null +++ b/src/main/java/aquality/selenium/elements/interfaces/IMultiChoiceBox.java @@ -0,0 +1,65 @@ +package aquality.selenium.elements.interfaces; + +import java.util.List; + +public interface IMultiChoiceBox extends IComboBox { + + /** + * Gets value of all selected options + * + * @return selected values + */ + List getSelectedValues(); + + /** + * Gets text of all selected options + * + * @return selected text + */ + List getSelectedTexts(); + + /** + * Select all options + */ + void selectAll(); + + /** + * Deselect all selected options + */ + void deselectAll(); + + /** + * Deselect selected option by index + * + * @param index number of selected option + */ + void deselectByIndex(int index); + + /** + * Deselect selected option by value + * + * @param value argument value + */ + void deselectByValue(String value); + + /** + * Deselect selected option by containing value + * + * @param value partial option's value + */ + void deselectByContainingValue(String value); + + /** + * Deselect selected option by visible text + * + * @param text text to be deselected + */ + void deselectByText(String text); + + /** + * Deselect selected option by containing visible text + * + * @param text visible text + */ + void deselectByContainingText(String text); +} diff --git a/src/main/resources/localization/be.json b/src/main/resources/localization/be.json index f9eefda..2840c4e 100644 --- a/src/main/resources/localization/be.json +++ b/src/main/resources/localization/be.json @@ -43,7 +43,11 @@ "loc.combobox.get.text.js": "Атрымліваем выбраны тэкст праз JavaScript", "loc.combobox.texts": "Спіс тэкстаў опцыяў: [%s]", "loc.combobox.values": "Спіс значэнняў: [%s]", - "loc.combobox.impossible.to.select.contain.value.or.text": "Немагчыма выбраць опцыю, якая змяшчае значэнне/тэкст '%1$s' у камбабоксе '%2$s'", + "loc.combobox.impossible.to.find.option.contain.value.or.text": "Немагчыма знайсці опцыю, якая змяшчае значэнне/тэкст '%1$s' у камбабоксе '%2$s'", + "loc.multichoicebox": "Камбабокс з мульцівыбарам", + "loc.multichoicebox.select.all": "Выбіраем усе значэнні", + "loc.multichoicebox.deselect.all": "Адмяняем выбар усіх значэнняў", + "loc.multichoicebox.deselect.by.text": "Адмяняем выбар значэння з тэкстам '%s'", "loc.el.getattr": "Атрымліваем атрыбут '%1$s'", "loc.el.attr.value": "Значэнне атрыбута '%1$s': [%2$s]", "loc.el.attr.set": "Задаем значэнне атрыбута '%1$s': [%2$s]", @@ -68,6 +72,7 @@ "loc.scrolling.center.js": "Пракручваем старонку да цэнтра элемента праз JavaScript", "loc.scrolling.js": "Пракручваем старонку праз JavaScript", "loc.selecting.value": "Выбіраем значэнне - '%s'", + "loc.deselecting.value": "Адмяняем выбар значэння - '%s'", "loc.send.text": "Задаем тэкст - '%s'", "loc.setting.value": "Задаем значэнне - '%s'", "loc.text.clearing": "Ачышчаем", diff --git a/src/main/resources/localization/en.json b/src/main/resources/localization/en.json index f3f12e8..fde73ae 100644 --- a/src/main/resources/localization/en.json +++ b/src/main/resources/localization/en.json @@ -43,7 +43,11 @@ "loc.combobox.get.text.js": "Getting selected text via JavaScript", "loc.combobox.texts": "Option texts: [%s]", "loc.combobox.values": "Option values: [%s]", - "loc.combobox.impossible.to.select.contain.value.or.text": "It is impossible to select option that contains value/text '%1$s' from combobox '%2$s'", + "loc.combobox.impossible.to.find.option.contain.value.or.text": "It is impossible to find an option that contains value/text '%1$s' from combobox '%2$s'", + "loc.multichoicebox": "Multi-choice ComboBox", + "loc.multichoicebox.select.all": "Select all", + "loc.multichoicebox.deselect.all": "Deselect all", + "loc.multichoicebox.deselect.by.text": "Deselecting value by text '%s'", "loc.el.getattr": "Getting attribute '%1$s'", "loc.el.attr.value": "Value of attribute '%1$s': [%2$s]", "loc.el.attr.set": "Setting value of attribute '%1$s': [%2$s]", @@ -68,6 +72,7 @@ "loc.scrolling.center.js": "Scrolling to the center via JavaScript", "loc.scrolling.js": "Scrolling via JavaScript", "loc.selecting.value": "Selecting value - '%s'", + "loc.deselecting.value": "Deselecting value - '%s'", "loc.send.text": "Setting text - '%s'", "loc.setting.value": "Setting value - '%s'", "loc.text.clearing": "Clearing", diff --git a/src/main/resources/localization/pl.json b/src/main/resources/localization/pl.json index 5d95097..20df9ba 100644 --- a/src/main/resources/localization/pl.json +++ b/src/main/resources/localization/pl.json @@ -43,7 +43,11 @@ "loc.combobox.get.text.js": "Pobieranie wybranego tekstu przez JavaScript", "loc.combobox.texts": "Lista tekstów opcji: [%s]", "loc.combobox.values": "Lista wartości: [%s]", - "loc.combobox.impossible.to.select.contain.value.or.text": "Wybieranie wartości ze znaczeniem/tekstem '%1$s' w polu kombi '%2$s' nie jest możliwe", + "loc.combobox.impossible.to.find.option.contain.value.or.text": "Znalezienie wartości ze znaczeniem/tekstem '%1$s' w polu kombi '%2$s' nie jest możliwe", + "loc.multichoicebox": "Pole kombi z multiwyborem", + "loc.multichoicebox.select.all": "Wybieranie wszystkich wartości", + "loc.multichoicebox.deselect.all": "Anulowanie wybierania wszystkich wartości", + "loc.multichoicebox.deselect.by.text": "Anulowanie wybierania wartości z tekstem '%s'", "loc.el.getattr": "Pobieranie atrybutu '%1$s'", "loc.el.attr.value": "Wartość atrybutu '%1$s': [%2$s]", "loc.el.attr.set": "Ustawianie wartości atrybutu '%1$s': [%2$s]", @@ -68,6 +72,7 @@ "loc.scrolling.center.js": "Przewijanie do centrum przez JavaScript", "loc.scrolling.js": "Przewijanie przez JavaScript", "loc.selecting.value": "Wybieranie wartości - '%s'", + "loc.deselecting.value": "Anulowanie wybierania wartości - '%s'", "loc.send.text": "Ustawianie tekstu - '%s'", "loc.setting.value": "Ustawienie wartości - '%s'", "loc.text.clearing": "Oczyszczenie", diff --git a/src/main/resources/localization/ru.json b/src/main/resources/localization/ru.json index 6a5199b..647ecff 100644 --- a/src/main/resources/localization/ru.json +++ b/src/main/resources/localization/ru.json @@ -43,7 +43,11 @@ "loc.combobox.get.text.js": "Получение текста выбранного значения посредством JavaScript", "loc.combobox.texts": "Список текстов опций: [%s]", "loc.combobox.values": "Список значений: [%s]", - "loc.combobox.impossible.to.select.contain.value.or.text": "Не удаётся выбрать значение которое содержит значение/текст '%1$s' в выпадающем списке '%2$s'", + "loc.combobox.impossible.to.find.option.contain.value.or.text": "Не удаётся найти опцию, которая содержит значение/текст '%1$s' в выпадающем списке '%2$s'", + "loc.multichoicebox": "Комбобокс с мультивыбором", + "loc.multichoicebox.select.all": "Выбор всех значений", + "loc.multichoicebox.deselect.all": "Отмена выбора всех значений", + "loc.multichoicebox.deselect.by.text": "Отмена выбора значения с текстом '%s'", "loc.el.getattr": "Получение аттрибута '%1$s'", "loc.el.attr.value": "Значение аттрибута '%1$s'': [%2$s]", "loc.el.attr.set": "Установка значения атрибута '%1$s': [%2$s]", @@ -68,6 +72,7 @@ "loc.scrolling.center.js": "Скроллинг в центр (посредством JavaScript)", "loc.scrolling.js": "Скроллинг посредством JavaScript", "loc.selecting.value": "Выбор значения - '%s'", + "loc.deselecting.value": "Отмена выбора значения - '%s'", "loc.send.text": "Ввод текста - '%s'", "loc.setting.value": "Установка значения - '%s'", "loc.text.clearing": "Очистка", diff --git a/src/main/resources/localization/uk.json b/src/main/resources/localization/uk.json index a2c18ae..436d08b 100644 --- a/src/main/resources/localization/uk.json +++ b/src/main/resources/localization/uk.json @@ -43,7 +43,11 @@ "loc.combobox.get.text.js": "Отримання вибраного тексту за допомогою JavaScript", "loc.combobox.texts": "Тексти опцій: [%s]", "loc.combobox.values": "Значення опцій: [%s]", - "loc.combobox.impossible.to.select.contain.value.or.text": "Неможливо вибрати опцію, що зміщує значення/текст '%1$s' у комбобоксі '%2$s'", + "loc.combobox.impossible.to.find.option.contain.value.or.text": "Неможливо знайти опцію, що містіть значення/текст '%1$s' у комбобоксі '%2$s'", + "loc.multichoicebox": "Комбобокс з мультівибором", + "loc.multichoicebox.select.all": "Вибір всіх значень", + "loc.multichoicebox.deselect.all": "Скасування вибору всіх значень", + "loc.multichoicebox.deselect.by.text": "Скасування вибору значення за текстом '%s'", "loc.el.getattr": "Отримання атрибута '%1$s'", "loc.el.attr.value": "Значення атрибута '%1$s': [%2$s]", "loc.el.attr.set": "Встановлення значення атрибута '%1$s': [%2$s]", @@ -68,6 +72,7 @@ "loc.scrolling.center.js": "Прокрутка до центру за допомогою JavaScript", "loc.scrolling.js": "Прокрутка за допомогою JavaScript", "loc.selecting.value": "Вибір значення - '%s'", + "loc.deselecting.value": "Скасування выбору значення - '%s'", "loc.send.text": "Встановлення тексту - '%s'", "loc.setting.value": "Встановлення значення - '%s'", "loc.text.clearing": "Очищення", diff --git a/src/test/java/tests/integration/ElementTests.java b/src/test/java/tests/integration/elements/ElementTests.java similarity index 99% rename from src/test/java/tests/integration/ElementTests.java rename to src/test/java/tests/integration/elements/ElementTests.java index d798928..1a1fba6 100644 --- a/src/test/java/tests/integration/ElementTests.java +++ b/src/test/java/tests/integration/elements/ElementTests.java @@ -1,4 +1,4 @@ -package tests.integration; +package tests.integration.elements; import aquality.selenium.browser.AqualityServices; import aquality.selenium.core.elements.ElementState; diff --git a/src/test/java/tests/integration/HiddenElementsTests.java b/src/test/java/tests/integration/elements/HiddenElementsTests.java similarity index 98% rename from src/test/java/tests/integration/HiddenElementsTests.java rename to src/test/java/tests/integration/elements/HiddenElementsTests.java index ff791d4..bebe1e8 100644 --- a/src/test/java/tests/integration/HiddenElementsTests.java +++ b/src/test/java/tests/integration/elements/HiddenElementsTests.java @@ -1,4 +1,4 @@ -package tests.integration; +package tests.integration.elements; import aquality.selenium.core.elements.ElementState; import aquality.selenium.core.elements.ElementsCount; diff --git a/src/test/java/tests/integration/elements/MultiChoiceBoxTests.java b/src/test/java/tests/integration/elements/MultiChoiceBoxTests.java new file mode 100644 index 0000000..4eaaa1b --- /dev/null +++ b/src/test/java/tests/integration/elements/MultiChoiceBoxTests.java @@ -0,0 +1,104 @@ +package tests.integration.elements; + +import org.testng.Assert; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; +import tests.BaseTest; +import w3schools.W3SchoolsPage; +import w3schools.forms.SelectMultipleForm; + +import java.util.List; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +public class MultiChoiceBoxTests extends BaseTest { + + private final SelectMultipleForm selectMultipleForm = new SelectMultipleForm(); + + @BeforeMethod + @Override + public void beforeMethod() { + getBrowser().goTo(W3SchoolsPage.SELECT_MULTIPLE.getAddress()); + getBrowser().setWindowSize(defaultSize.width, defaultSize.height); + selectMultipleForm.acceptCookies(); + selectMultipleForm.switchToResultFrame(); + } + + @Test + public void testSelectAll() { + List allTexts = selectMultipleForm.getAllTexts(); + + selectMultipleForm.selectAll(); + List selected = selectMultipleForm.getSelectedTexts(); + Assert.assertEquals(allTexts, selected, "Not all texts were selected"); + + selected = selectMultipleForm.getSelectedValues(); + selectMultipleForm.submit(); + + Assert.assertEquals(selectMultipleForm.getValuesFromResult(), selected); + } + + @Test + public void testDeselectByValue() { + List valuesToRemove = Stream.of("volvo", "saab").collect(Collectors.toList()); + + selectMultipleForm.selectAll(); + List remaining = selectMultipleForm.deselectByValue(valuesToRemove); + selectMultipleForm.submit(); + + Assert.assertEquals(selectMultipleForm.getValuesFromResult(), remaining); + } + + @Test + public void testDeselectByContainingValue() { + List valuesToRemove = Stream.of("saa", "ope").collect(Collectors.toList()); + + selectMultipleForm.selectAll(); + List remaining = selectMultipleForm.deselectByContainingValue(valuesToRemove); + selectMultipleForm.submit(); + + Assert.assertEquals(selectMultipleForm.getValuesFromResult(), remaining); + } + + @Test + public void testDeselectByText() { + List valuesToRemove = Stream.of("Opel").collect(Collectors.toList()); + + selectMultipleForm.selectAll(); + List remaining = selectMultipleForm.deselectByText(valuesToRemove); + selectMultipleForm.submit(); + + Assert.assertEquals(selectMultipleForm.getValuesFromResult(), remaining); + } + + @Test + public void testDeselectByContainingText() { + List valuesToRemove = Stream.of("Au", "Vol").collect(Collectors.toList()); + + selectMultipleForm.selectAll(); + List remaining = selectMultipleForm.deselectByContainingText(valuesToRemove); + selectMultipleForm.submit(); + + Assert.assertEquals(selectMultipleForm.getValuesFromResult(), remaining); + } + + @Test + public void testDeselectByIndex() { + List valuesToRemove = Stream.of(2, 3).collect(Collectors.toList()); + + selectMultipleForm.selectAll(); + List remaining = selectMultipleForm.deselectByIndex(valuesToRemove); + selectMultipleForm.submit(); + + Assert.assertEquals(selectMultipleForm.getValuesFromResult(), remaining); + } + + @Test + public void testDeselectAll() { + selectMultipleForm.selectAll(); + selectMultipleForm.deselectAll(); + selectMultipleForm.submit(); + + Assert.assertTrue(selectMultipleForm.getValuesFromResult().isEmpty()); + } +} diff --git a/src/test/java/w3schools/W3SchoolsPage.java b/src/test/java/w3schools/W3SchoolsPage.java new file mode 100644 index 0000000..12dc989 --- /dev/null +++ b/src/test/java/w3schools/W3SchoolsPage.java @@ -0,0 +1,17 @@ +package w3schools; + +public enum W3SchoolsPage { + SELECT_MULTIPLE("tryhtml_select_multiple"); + + private static final String BASE_URL = "https://www.w3schools.com/tags/tryit.asp"; + + private final String postfix; + + W3SchoolsPage(String postfix) { + this.postfix = postfix; + } + + public String getAddress() { + return BASE_URL.concat(String.format("?filename=%s", postfix)); + } +} diff --git a/src/test/java/w3schools/forms/SelectMultipleForm.java b/src/test/java/w3schools/forms/SelectMultipleForm.java new file mode 100644 index 0000000..7277e83 --- /dev/null +++ b/src/test/java/w3schools/forms/SelectMultipleForm.java @@ -0,0 +1,112 @@ +package w3schools.forms; + +import aquality.selenium.browser.AqualityServices; +import aquality.selenium.elements.interfaces.IButton; +import aquality.selenium.elements.interfaces.IMultiChoiceBox; +import aquality.selenium.elements.interfaces.ITextBox; +import aquality.selenium.forms.Form; +import org.openqa.selenium.By; + +import java.util.ArrayList; +import java.util.List; +import java.util.function.Consumer; +import java.util.regex.Matcher; +import java.util.regex.Pattern; +import java.util.stream.Collectors; +import java.util.stream.IntStream; + +public class SelectMultipleForm extends Form { + + private final IMultiChoiceBox cbxCars = getElementFactory().getMultiChoiceBox(By.id("cars"), "Cars"); + private final IButton btnSubmit = getElementFactory().getButton(By.cssSelector("input[type='submit']"), "Submit"); + private final ITextBox txbResult = getElementFactory().getTextBox(By.cssSelector(".w3-large"), "Result"); + private final IButton btnAcceptCookies = getElementFactory().getButton(By.id("accept-choices"), "Accept cookies"); + + public SelectMultipleForm() { + super(By.id("iframe"), "Select Multiple"); + } + + public void acceptCookies() { + if (btnAcceptCookies.state().isDisplayed()) { + btnAcceptCookies.click(); + btnAcceptCookies.state().waitForNotDisplayed(); + } + } + + public void switchToResultFrame() { + AqualityServices.getBrowser().getDriver().switchTo().frame("iframeResult"); + } + + public void submit() { + btnSubmit.click(); + } + + public List getValuesFromResult() { + String result = txbResult.getText().trim(); + + List results = new ArrayList<>(); + Pattern pattern = Pattern.compile(".*?=(.*?)(&|$)"); + Matcher matcher = pattern.matcher(result); + while (matcher.find()) { + results.add(matcher.group(1)); + } + return results; + } + + public void selectAll() { + cbxCars.selectAll(); + } + + public List getAllTexts() { + return cbxCars.getTexts(); + } + + public List getSelectedTexts() { + return cbxCars.getSelectedTexts(); + } + + public List getSelectedValues() { + return cbxCars.getSelectedValues(); + } + + public List deselectByValue(List valuesToDeselect) { + return deselectBy(cbxCars::deselectByValue, valuesToDeselect); + } + + public List deselectByContainingValue(List valuesToDeselect) { + return deselectBy(cbxCars::deselectByContainingValue, valuesToDeselect); + } + + public List deselectByText(List textToDeselect) { + return deselectBy(cbxCars::deselectByText, textToDeselect); + } + + public List deselectByContainingText(List textToDeselect) { + return deselectBy(cbxCars::deselectByContainingText, textToDeselect); + } + + public List deselectByIndex(List indicesToDeselect) { + List values = cbxCars.getValues(); + indicesToDeselect.forEach(cbxCars::deselectByIndex); + return IntStream.range(0, values.size()) + .filter(i -> !indicesToDeselect.contains(i)) + .mapToObj(values::get) + .collect(Collectors.toList()); + } + + public void deselectAll() { + cbxCars.deselectAll(); + } + + private List deselectBy(Consumer deselectFunc, List valuesToDeselect) { + valuesToDeselect.forEach(deselectFunc); + return collectRemaining(valuesToDeselect); + } + + private List collectRemaining(List valuesToDeselect) { + return cbxCars.getValues().stream() + .filter(v -> valuesToDeselect.stream() + .noneMatch(deselected -> v.contains(deselected.toLowerCase()))) + .collect(Collectors.toList()); + } +} diff --git a/src/test/resources/TestSuite.xml b/src/test/resources/TestSuite.xml index f3f5c7b..018b7be 100644 --- a/src/test/resources/TestSuite.xml +++ b/src/test/resources/TestSuite.xml @@ -7,9 +7,9 @@ - + - + @@ -42,6 +42,7 @@ +