From 845db9fcdf85af71ace8ab5072bb49cfe402d7ef Mon Sep 17 00:00:00 2001 From: vculea Date: Tue, 29 Oct 2024 09:39:26 +0200 Subject: [PATCH] added doSelect(List searchTypes, Duration duration, boolean holdOpen, List values) method in TagField --- .../sdl/selenium/extjs6/form/TagField.java | 50 ++++++++++++++----- 1 file changed, 37 insertions(+), 13 deletions(-) diff --git a/src/main/java/com/sdl/selenium/extjs6/form/TagField.java b/src/main/java/com/sdl/selenium/extjs6/form/TagField.java index f394aba3..eeff0dbf 100644 --- a/src/main/java/com/sdl/selenium/extjs6/form/TagField.java +++ b/src/main/java/com/sdl/selenium/extjs6/form/TagField.java @@ -60,6 +60,12 @@ public boolean select(SearchType searchType, String... values) { return selected; } + public boolean select(List searchTypes, List values) { + boolean selected = doSelect(searchTypes, Duration.ofMillis(300), true, values); + assertThat("Could not selected value on : " + this, selected, is(true)); + return selected; + } + public boolean select(SearchType searchType, Duration duration, String... values) { boolean selected = doSelect(searchType, duration, true, values); assertThat("Could not selected value on : " + this, selected, is(true)); @@ -84,33 +90,51 @@ public boolean doSelect(SearchType searchType, long optionRenderMillis, boolean } /** - * @param searchType use {@link SearchType} - * @param duration eg. 300ms - * @param holdOpen true | false - * @param values values[] + * @param searchType use {@link SearchType} + * @param duration eg. 300ms + * @param holdOpen true | false + * @param values values[] * @return true if value was selected */ public boolean doSelect(SearchType searchType, Duration duration, boolean holdOpen, String... values) { + return doSelect(List.of(searchType), duration, holdOpen, Arrays.asList(values)); + } + + public boolean doSelect(List searchTypes, List values) { + return doSelect(searchTypes, Duration.ofMillis(300), true, values); + } + + public boolean doSelect(List searchTypes, Duration duration, List values) { + return doSelect(searchTypes, duration, true, values); + } + + /** + * @param searchTypes List searchTypes, use {@link SearchType} + * @param duration eg. Duration.ofMillis(300) + * @param holdOpen true | false + * @param values List values + * @return true if value was selected + */ + public boolean doSelect(List searchTypes, Duration duration, boolean holdOpen, List values) { boolean selected = true; String info = toString(); ready(); List selectedValues = getAllSelectedValues(); - List valuesList = List.of(values); List selectValues = new ArrayList<>(); - for (String value : valuesList) { - if(!selectedValues.contains(value)){ + for (String value : values) { + if (!selectedValues.contains(value)) { selectValues.add(value); } } if (holdOpen) { if (expand()) { for (String value : selectValues) { - WebLocator option = getComboEl(value, duration, searchType); + WebLocator option = getComboEl(value, duration, searchTypes.toArray(new SearchType[0])); selected = selected && option.doClick(); if (selected) { - log.info("Set value(" + info + "): " + value); + log.info("Set value({}): {}", info, value); } else { - log.debug("(" + info + ") The option '" + value + "' could not be located. " + option.getXPath()); + log.debug("({}) The option '{}' could not be located. {}", info, value, option.getXPath()); } } collapse(); // to close combo @@ -118,13 +142,13 @@ public boolean doSelect(SearchType searchType, Duration duration, boolean holdOp } else { for (String value : selectValues) { expand(); - WebLocator option = getComboEl(value, duration, searchType); + WebLocator option = getComboEl(value, duration, searchTypes.toArray(new SearchType[0])); selected = selected && option.doClick(); if (selected) { - log.info("Set value(" + info + "): " + value); + log.info("Set value({}): {}", info, value); collapse(); } else { - log.debug("(" + info + ") The option '" + value + "' could not be located. " + option.getXPath()); + log.debug("({}) The option '{}' could not be located. {}", info, value, option.getXPath()); } } }