return optionTexts;
}
+ public List<String> getOptionsCssClasses() {
+ List<String> optionTexts = new ArrayList<>();
+ List<WebElement> options = findElements(byButtonSpan);
+ for (WebElement option : options) {
+ optionTexts.add(option.getAttribute("class"));
+ }
+ return optionTexts;
+ }
+
+ public List<String> getOptionsIconUrls() {
+ List<String> icons = new ArrayList<>();
+ List<WebElement> options = findElements(byButtonSpan);
+ for (WebElement option : options) {
+ List<WebElement> images = option.findElements(By.tagName("img"));
+ if (images != null && images.size() > 0) {
+ icons.add(images.get(0).getAttribute("src"));
+ } else {
+ icons.add(null);
+ }
+
+ }
+ return icons;
+ }
+
public void selectByText(String text) throws ReadOnlyException {
if (isReadOnly()) {
throw new ReadOnlyException();
"Clear operation is not supported for CheckBoxGroup."
+ " This operation has no effect on the element.");
}
+
}
return (Class) CheckBoxGroup.class;
}
+
+ @Override
+ protected CheckBoxGroup<Object> constructComponent() {
+ CheckBoxGroup<Object> checkBoxGroup = super.constructComponent();
+ checkBoxGroup.setItemIconProvider(
+ item -> "Item 2".equals(item) ? ICON_16_HELP_PNG_CACHEABLE :
+ null);
+ checkBoxGroup.setItemEnabledProvider(item -> !"Item 10".equals(item));
+ return checkBoxGroup;
+ }
+
@Override
protected void createActions() {
super.createActions();
/*
* Copyright 2000-2014 Vaadin Ltd.
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
import com.vaadin.testbench.customelements.CheckBoxGroupElement;
import com.vaadin.tests.components.checkbox.CheckBoxGroupTestUI;
import com.vaadin.tests.tb3.MultiBrowserTest;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.util.List;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
/**
* Test for CheckBoxGroup
}
assertEquals("Number of items", count, i);
}
+
+ @Test
+ public void testDisabled() {
+ List<String> optionsCssClasses = getSelect().getOptionsCssClasses();
+ for (int i = 0; i < optionsCssClasses.size(); i++) {
+ String cssClassList = optionsCssClasses.get(i);
+ if (i == 10) {
+ assertTrue("10th item should be disabled",
+ cssClassList.toLowerCase().contains("disabled"));
+ } else {
+ assertFalse("Only 10th item should be disabled",
+ cssClassList.toLowerCase().contains("disabled"));
+ }
+ }
+ }
+
+ @Test
+ public void testIconUrl() {
+ List<String> optionsIcons = getSelect().getOptionsIconUrls();
+ for (int i = 0; i < optionsIcons.size(); i++) {
+ String icon = optionsIcons.get(i);
+ if (i == 2) {
+ assertNotNull("2nd item should have icon", icon);
+ } else {
+ assertNull("Only 2nd item should have icon", icon);
+ }
+ }
+ }
}