本文整理了Java中org.openqa.selenium.support.ui.Select.isMultiple()
方法的一些代码示例,展示了Select.isMultiple()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Select.isMultiple()
方法的具体详情如下:
包路径:org.openqa.selenium.support.ui.Select
类名称:Select
方法名:isMultiple
暂无
代码示例来源:origin: selenide/selenide
@Override
public Void execute(SelenideElement proxy, WebElementSource selectField, Object[] args) {
String text = (String) args[0];
WebElement element = selectField.getWebElement();
Select select = new Select(element);
List<WebElement> options = element.findElements(By.xpath(
".//option[contains(normalize-space(.), " + Quotes.escape(text) + ")]"));
if (options.isEmpty()) {
throw new NoSuchElementException("Cannot locate option containing text: " + text);
}
for (WebElement option : options) {
setSelected(option);
if (!select.isMultiple()) {
break;
}
}
return null;
}
代码示例来源:origin: spring-io/initializr
private Object getInputValue(WebElement input) {
Object value = null;
String type = input.getAttribute("type");
if ("select".equals(input.getTagName())) {
Select select = new Select(input);
if (select.isMultiple()) {
value = select.getAllSelectedOptions().stream().map(this::getValue)
.collect(Collectors.toList());
}
else {
value = getValue(select.getFirstSelectedOption());
}
}
else if (Arrays.asList("checkbox", "radio").contains(type)) {
if (input.isSelected()) {
value = getValue(input);
}
else {
if (Objects.equals(type, "checkbox")) {
value = false;
}
}
}
else {
value = getValue(input);
}
return value;
}
代码示例来源:origin: elisarver/selophane
/**
* Wraps Selenium's method.
*
* @return boolean if this is a multiselect.
* @see org.openqa.selenium.support.ui.Select#isMultiple()
*/
public boolean isMultiple() {
return innerSelect.isMultiple();
}
代码示例来源:origin: MarkusBernhardt/robotframework-selenium2library-java
protected boolean isMultiselectList(Select select) {
return select.isMultiple();
}
代码示例来源:origin: yandex-qatools/htmlelements
/**
* Indicates whether this select element support selecting multiple options at the same time.
* This is done by checking the value of the "multiple" attribute.
*
* @return {@code true} if select element support selecting multiple options and {@code false} otherwise.
*/
public boolean isMultiple() {
return getSelect().isMultiple();
}
代码示例来源:origin: com.github.bordertech.wcomponents/wcomponents-test-lib
/**
* Is the component a multi-select list?
*
* @return {@code true} if the component is a multi-select
*/
public boolean isMultiSelect() {
Select se = new Select(this);
return se.isMultiple();
}
代码示例来源:origin: org.bitbucket.iamkenos/cissnei-selenium
public Boolean isDropdownForMultiSelection(WebElement element) {
try {
return driverDropdown(element).isMultiple();
} catch (Exception e) {
return FALSE;
}
}
代码示例来源:origin: ru.yandex.qatools.htmlelements/htmlelements-java
/**
* Indicates whether this select element support selecting multiple options at the same time.
* This is done by checking the value of the "multiple" attribute.
*
* @return {@code true} if select element support selecting multiple options and {@code false} otherwise.
*/
public boolean isMultiple() {
return getSelect().isMultiple();
}
代码示例来源:origin: ru.sbtqa.htmlelements/htmlelements-java
/**
* Indicates whether this select element support selecting multiple options at the same time.
* This is done by checking the value of the "multiple" attribute.
*
* @return {@code true} if select element support selecting multiple options and {@code false} otherwise.
*/
public boolean isMultiple() {
return getSelect().isMultiple();
}
代码示例来源:origin: org.seleniumhq.selenium.fluent/fluent-selenium
public Boolean execute() {
return getSelect().isMultiple();
}
}
代码示例来源:origin: stackoverflow.com
Select selectElement = new Select(driver.findElement(By.Id("productId")));
if (selectElement.isMultiple()) { /* step 1 */
List<WebElement> options = selectElement.getOptions(); /* step 2 */
for (WebElement we : options) { /* step 3 */
we.selectByVisibleText(we.getText());
}
} else {
// does not support multiple
}
代码示例来源:origin: org.seleniumhq.webdriver/webdriver-support
/**
* Select the option at the given index. This is done by examing the "index" attribute of an
* element, and not merely by counting.
*
* @param index The option at this index will be selected
*/
public void selectByIndex(int index) {
String match = String.valueOf(index);
for (WebElement option : getOptions()) {
if (match.equals(option.getAttribute("index"))) {
option.setSelected();
if (isMultiple()) { return; }
}
}
}
代码示例来源:origin: org.openqa.selenium.webdriver/webdriver-support
/**
* Select the option at the given index. This is done by examing the "index" attribute of an
* element, and not merely by counting.
*
* @param index The option at this index will be selected
*/
public void selectByIndex(int index) {
String match = String.valueOf(index);
for (WebElement option : getOptions()) {
if (match.equals(option.getAttribute("index"))) {
option.setSelected();
if (isMultiple()) { return; }
}
}
}
代码示例来源:origin: viltgroup/minium
@Override
protected void doPerform() {
Select select = getSelectElement();
if (!select.isMultiple()) {
throw new UnsupportedOperationException("You may only deselect all options of a multi-select");
}
for (WebElement option : select.getOptions()) {
if (!option.isSelected()) {
option.click();
}
}
}
}
代码示例来源:origin: com.epam.jdi/jdi-light
@Override
public void setValue(String value) {
if (select().isMultiple())
check(value.split(";"));
else select(value);
}
@Override
代码示例来源:origin: org.openqa.selenium.webdriver/webdriver-support
/**
* Clear all selected entries. This is only valid when the SELECT supports multiple selections.
*
* @throws UnsupportedOperationException If the SELECT does not support multiple selections
*/
public void deselectAll() {
if (!isMultiple()) {
throw new UnsupportedOperationException(
"You may only deselect all options of a multi-select");
}
for (WebElement option : getOptions()) {
if (option.isSelected()) {
option.toggle();
}
}
}
代码示例来源:origin: com.epam.jdi/jdi-light
@Override
public String getValue() {
return select().isMultiple() ? print(checked(),";") : selected();
}
代码示例来源:origin: org.finra.jtaf/jtaf-extwebdriver
/**
*
* @param options the options that are being selected
* @throws WidgetException
*/
private void selectMultiple(List<String> options) throws WidgetException {
org.openqa.selenium.support.ui.Select selectBox = new org.openqa.selenium.support.ui.Select(
findElement());
if (!selectBox.isMultiple()) {
throw new WidgetException("This is not multiple select box", getByLocator());
}
for (String option : options) {
selectBox.selectByVisibleText(option);
}
}
代码示例来源:origin: FINRAOS/JTAF-ExtWebDriver
/**
*
* @param options the options that are being selected
* @throws WidgetException
*/
private void selectMultiple(List<String> options) throws WidgetException {
org.openqa.selenium.support.ui.Select selectBox = new org.openqa.selenium.support.ui.Select(
findElement());
if (!selectBox.isMultiple()) {
throw new WidgetException("This is not multiple select box", getByLocator());
}
for (String option : options) {
selectBox.selectByVisibleText(option);
}
}
代码示例来源:origin: vmi/selenese-runner-java
/**
* Constructor.
*
* @param context context.
* @param selectLocator select locator.
*/
public SelectElement(Context context, String selectLocator) {
WebDriver driver = context.getWrappedDriver();
finder = context.getElementFinder();
select = finder.findElement(driver, selectLocator);
context.getJSLibrary().replaceAlertMethod(driver, select);
selectUI = new Select(select);
isMultiple = selectUI.isMultiple();
}
内容来源于网络,如有侵权,请联系作者删除!