com.sdl.selenium.extjs6.button.SplitButton Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of Testy Show documentation
Show all versions of Testy Show documentation
Automated Acceptance Testing. Selenium and Selenium WebDriver test framework for web applications.
(optimized for dynamic html, ExtJS, Bootstrap, complex UI, simple web applications/sites)
The newest version!
package com.sdl.selenium.extjs6.button;
import com.sdl.selenium.extjs6.menu.Menu;
import com.sdl.selenium.web.SearchType;
import com.sdl.selenium.web.WebLocator;
import org.slf4j.Logger;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
/**
* See split button examples here
*/
public class SplitButton extends Button {
private static final Logger log = org.slf4j.LoggerFactory.getLogger(SplitButton.class);
/**
* See split button examples here
*/
public SplitButton() {
setClassName("SplitButton");
}
public SplitButton(WebLocator container) {
this();
setContainer(container);
}
public SplitButton(WebLocator container, String text, SearchType... searchTypes) {
this(container);
if (searchTypes.length == 0) {
searchTypes = new SearchType[]{SearchType.EQUALS};
}
setText(text, searchTypes);
}
public void clickOnMenu(String... options) {
assertReady();
clickOnMenu(SearchType.CONTAINS, options);
}
public boolean doClickOnMenu(String... options) {
return doClickOnMenu(SearchType.CONTAINS, options);
}
public void clickOnMenu(SearchType searchType, String... options) {
assertReady();
Menu menu = new Menu();
if (menu.showMenu(this) || menu.showMenu(this)) {
for (String option : options) {
menu.clickOnMenu(option, searchType);
}
} else {
log.debug("(" + this + ") The element arrow could not be located.");
}
}
public boolean mouseOverAndClickOnMenu(SearchType searchType, String... options) {
assertReady();
Menu menu = new Menu();
if (menu.showMenu(this) || menu.showMenu(this)) {
int length = options.length;
boolean success = true;
for (int i = 0; i < length; i++) {
String option = options[i];
if (i == length - 1) {
success = success && menu.doClickOnMenu(option, searchType);
} else {
success = success && menu.mouseOverOnMenu(option, searchType);
}
}
return success;
} else {
log.debug("(" + this + ") The element arrow could not be located.");
return false;
}
}
public boolean doClickOnMenu(SearchType searchType, String... options) {
boolean success = true;
Menu menu = new Menu();
if (menu.showMenu(this) || menu.showMenu(this)) {
for (String option : options) {
success = success && menu.doClickOnMenu(option, searchType);
}
} else {
log.debug("(" + this + ") The element arrow could not be located.");
success = false;
}
return success;
}
public List getAllMenuValues() {
Menu menu = new Menu();
if (!menu.showMenu(this)) {
menu.ready();
menu.showMenu(this);
}
List menuValues = menu.getMenuValues();
menu.hideMenu(this);
return menuValues;
}
public List getAllDisabledValues() {
Menu menu = new Menu();
if (!menu.showMenu(this)) {
menu.ready();
menu.showMenu(this);
}
List menuValues = menu.getMenuValuesWithStatus();
menu.hideMenu(this);
return menuValues.stream().map(i -> {
if (Boolean.parseBoolean(i.getEnabled())) {
return null;
} else {
return i.getName();
}
}).filter(Objects::nonNull).collect(Collectors.toList());
}
public List getAllEnabledValues() {
Menu menu = new Menu();
if (!menu.showMenu(this)) {
menu.ready();
menu.showMenu(this);
}
List menuValues = menu.getMenuValuesWithStatus();
menu.hideMenu(this);
return menuValues.stream().map(i -> {
if (Boolean.parseBoolean(i.getEnabled())) {
return i.getName();
} else {
return null;
}
}).filter(Objects::nonNull).collect(Collectors.toList());
}
public List getMenuValuesExtended() {
Menu menu = new Menu();
if (!menu.showMenu(this)) {
menu.ready();
menu.showMenu(this);
}
List menuValuesExtend = menu.getMenuValuesExtend();
menu.hideMenu(this);
return menuValuesExtend;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy