org.openqa.selenium.support.ui.Select.selectByIndex()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(5.7k)|赞(0)|评价(0)|浏览(139)

本文整理了Java中org.openqa.selenium.support.ui.Select.selectByIndex()方法的一些代码示例,展示了Select.selectByIndex()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Select.selectByIndex()方法的具体详情如下:
包路径:org.openqa.selenium.support.ui.Select
类名称:Select
方法名:selectByIndex

Select.selectByIndex介绍

[英]Select the option at the given index. This is done by examing the "index" attribute of an element, and not merely by counting.
[中]选择给定索引处的选项。这是通过检查元素的“索引”属性来实现的,而不仅仅是通过计数。

代码示例

代码示例来源:origin: selenide/selenide

private void selectOptionsByIndexes(WebElementSource selectField, int[] indexes) {
  Select select = new Select(selectField.getWebElement());
  for (int index : indexes) {
   try {
    select.selectByIndex(index);
   }
   catch (NoSuchElementException e) {
    throw new ElementNotFound(selectField.driver(), selectField.getSearchCriteria() + "/option[index:" + index + ']', exist, e);
   }
  }
 }
}

代码示例来源:origin: stackoverflow.com

if(stateDropdown.isEnabled()&&(!stateField.isEnabled())){

  Select state = new Select(stateDropdown);
  // state.selectByValue("Illinois");
  state.selectByIndex(2);

}else if(stateField.isEnabled()&&(!stateDropdown.isEnabled){
  stateField.sendKeys("Salzburg");
}

代码示例来源:origin: stackoverflow.com

Select sele = new Select(driver.findElement(By.id("select_category")));

//Select the dropdown by using the displayed value.
sele.selectByVisibleText(`displayed value`);

//or you can Select the dropdown by using the index value.
sele.selectByIndex(`index value`);

 //or you can Select the dropdown by using the value attribute.
sele.selectByIndex(`value in the value attribute`);

代码示例来源:origin: org.xwiki.platform/xwiki-platform-test-ui

@Override
public void selectByIndex(int index)
{
  super.selectByIndex(index);
  maybeCloseDropDownList();
}

代码示例来源:origin: com.github.wiselenium/wiselenium-elements

@Override
public Select selectByIndex(int index) {
  this.getWrappedSelect().selectByIndex(index);
  return this;
}

代码示例来源:origin: yandex-qatools/htmlelements

/**
 * Select the option at the given index. This is done by examining 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) {
  getSelect().selectByIndex(index);
}

代码示例来源:origin: org.bitbucket.iamkenos/cissnei-selenium

public void dropdownSelectIndex(WebElement element, int index) {
  try {
    driverDropdown(element).selectByIndex(index);
  } catch (Exception e) {
    LOGGER.error(e.getMessage());
    throw e;
  }
}

代码示例来源:origin: ru.sbtqa.htmlelements/htmlelements-java

/**
 * Select the option at the given index. This is done by examining 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) {
  getSelect().selectByIndex(index);
}

代码示例来源:origin: com.github.wiselenium/wiselenium-core

@Override
public Select selectByIndex(int index) {
  this.getWrappedSelect().selectByIndex(index);
  return this;
}

代码示例来源:origin: com.github.wiselenium/wiselenium-elements

@Override
public MultiSelect selectByIndex(int... indexes) {
  for (int i : indexes)
    this.getWrappedSelect().selectByIndex(i);
  return this;
}

代码示例来源:origin: stackoverflow.com

Select dropdown = new Select(driver.findElement(By.id("designation")));
// To select its option say 'Programmer' you can do
dropdown.selectByVisibleText("Programmer ");
// or
dropdown.selectByIndex(1);
// or
dropdown.selectByValue("prog");

代码示例来源:origin: com.synaptix.redpepper/redpepper-automation

@Override
public void selectByIndex(int index) {
  WebElement find = frontEndDriver.find(wrappedElement);
  Select realSelect = new Select(find);
  realSelect.selectByIndex(index);
}

代码示例来源:origin: com.epam.jdi/jdi-light

/**
 * Selects the value based on its index
 * @param index int to search
 */
@JDIAction("Select '{0}' in '{name}'")
public void select(int index) {
  select().selectByIndex(index-1);
}

代码示例来源:origin: com.epam.jdi/jdi-uitest-web

public void selectOption(int... index) {
  Select selectField = new Select(getWebElement());
  for (int value: index) {
    selectField.selectByIndex(value);
  }
}

代码示例来源:origin: com.epam.jdi/jdi-light

@JDIAction("Select '{0}' in '{name}'")
public void select(int index) {
  if (expander != null && list != null) {
    expand();
    list.select(index);
  }
  else getSelectElement(format("select '%s'", index)).selectByIndex(index);
}
@JDIAction("Get '{name}' text")

代码示例来源:origin: qaprosoft/carina

@Override
public boolean doSelectByIndex(int index) {
  DriverListener.setMessages(
      Messager.SELECT_BY_INDEX_PERFORMED.getMessage(String.valueOf(index), getName()),
      Messager.SELECT_BY_INDEX_NOT_PERFORMED.getMessage(String.valueOf(index), getNameWithLocator()));
  
  
  final Select s = new Select(element);
  s.selectByIndex(index);
  return true;
}

代码示例来源:origin: com.epam.jdi/jdi-uitest-web

@Override
protected void selectListAction(int... indexes) {
  if (indexes == null || indexes.length == 0)
    return;
  if (button() != null) {
    expandAction(indexes[0]);
    super.selectListAction(indexes);
  } else
    for (int index : indexes)
      getSelector().selectByIndex(index);
}

代码示例来源:origin: epam/JDI

@Override
protected void selectListAction(int... indexes) {
  if (indexes == null || indexes.length == 0)
    return;
  if (button() != null) {
    expandAction(indexes[0]);
    super.selectListAction(indexes);
  } else
    for (int index : indexes)
      getSelector().selectByIndex(index);
}

代码示例来源:origin: net.serenity-bdd/serenity-core

public WebElementFacade byIndex(int indexValue) {
    if (webElementFacade.driverIsDisabled()) { return webElementFacade; }
    webElementFacade.waitUntilElementAvailable();
    Select select = new Select(webElementFacade.getElement());
    select.selectByIndex(indexValue);
    webElementFacade.notifyScreenChange();
    return webElementFacade;
  }
}

代码示例来源:origin: net.serenity-bdd/core

@Override
public WebElementFacade selectByIndex(int indexValue) {
  logIfVerbose("Select by index '" + indexValue + "'");
  enableHighlightingIfRequired();
  waitUntilElementAvailable();
  Select select = new Select(getElement());
  select.selectByIndex(indexValue);
  notifyScreenChange();
  return this;
}

相关文章