本文整理了Java中org.openqa.selenium.support.ui.Select.getOptions()
方法的一些代码示例,展示了Select.getOptions()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Select.getOptions()
方法的具体详情如下:
包路径:org.openqa.selenium.support.ui.Select
类名称:Select
方法名:getOptions
暂无
代码示例来源:origin: stackoverflow.com
WebElement select = driver.findElement(By.name("myselect"));
Select dropDown = new Select(select);
String selected = dropDown.getFirstSelectedOption().getText();
if(selected.equals(valueToSelect)){
//already selected;
//do stuff
}
List<WebElement> Options = dropDown.getOptions();
for(WebElement option:Options){
if(option.getText().equals(valueToSelect)) {
option.click(); //select option here;
}
}
代码示例来源:origin: yandex-qatools/htmlelements
/**
* Returns all options belonging to this select tag.
*
* @return A list of {@code WebElements} representing options.
*/
public List<WebElement> getOptions() {
return getSelect().getOptions();
}
代码示例来源:origin: org.seleniumhq.webdriver/webdriver-support
/**
* @return All selected options belonging to this select tag
*/
public List<WebElement> getAllSelectedOptions() {
List<WebElement> toReturn = new ArrayList<WebElement>();
for (WebElement option : getOptions()) {
if (option.isSelected()) {
toReturn.add(option);
}
}
return toReturn;
}
代码示例来源:origin: sayems/java.webdriver
public List<String> getAllValues(Supplier<By> by) {
return new Select(findElement(by)).getOptions()
.stream()
.map(option -> option.getAttribute(VALUE))
.collect(Collectors.toList());
}
代码示例来源:origin: sayems/java.webdriver
public boolean isTextPresentInTheDropdown(Supplier<By> by, String text) {
final Element element = untilFound(by);
Select dropdown = new Select(element);
return dropdown
.getOptions()
.parallelStream()
.anyMatch(opt -> opt.getText()
.contains(text));
}
代码示例来源:origin: stackoverflow.com
Select select = new Select(element);
Actions builder = new Actions(driver);
builder.keyDown(Keys.CONTROL)
.click(select.getOptions().get(2))
.keyUp(Keys.CONTROL);
builder.build().perform();
代码示例来源:origin: com.github.wiselenium/wiselenium-core
@Override
public MultiSelect selectAll() {
List<WebElement> selectOptions = this.getWrappedSelect().getOptions();
for (WebElement option : selectOptions)
if (!option.isSelected()) option.click();
return this;
}
代码示例来源:origin: com.github.webdriverextensions/webdriverextensions
public static boolean optionWithIndexIsDeselected(int index, WebElement webElement) {
List<WebElement> options = new Select(webElement).getOptions();
try {
return isDeselected(options.get(index));
} catch (IndexOutOfBoundsException e) {
return false;
}
}
代码示例来源:origin: com.github.webdriverextensions/webdriverextensions
public static boolean hasOptionWithValue(String value, WebElement webElement) {
List<WebElement> options = new Select(webElement).getOptions();
for (WebElement option : options) {
if (valueEquals(value, option)) {
return true;
}
}
return false;
}
代码示例来源:origin: stackoverflow.com
WebDriverWait wait = new WebDriverWait(driver, 20);
int size = 3;
for (int i = 2 ; i < size ; ++i) {
WebElement dropdown = driver.findElement(...);
Select select = new Select(dropdown);
size = select.getOptions().size(); //change the condition to the number of options
select.selectByIndex(i);
driver.findElement(...).click(); //download the report
wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("ReportViewerControl_AsyncWait_Wait"))); //wait for the loader to appear
wait.until(ExpectedConditions.invisibilityOfElementLocated(By.id("ReportViewerControl_AsyncWait_Wait"))); //wait for the loader to disappear
}
代码示例来源:origin: sayems/java.webdriver
public Integer getFirstSelectedIndex(Supplier<By> by) {
try {
Select select = new Select(findElement(by));
List<WebElement> options = select.getOptions();
if (!options.isEmpty()) {
return options.indexOf(select.getFirstSelectedOption());
}
return null;
} catch (NoSuchElementException e) {
return null;
}
}
代码示例来源:origin: webdriverextensions/webdriverextensions
public static boolean hasOption(String text, WebElement webElement) {
List<WebElement> options = new Select(webElement).getOptions();
for (WebElement option : options) {
if (textEquals(text, option)) {
return true;
}
}
return false;
}
代码示例来源:origin: org.seleniumhq.webdriver/webdriver-support
/**
* @return The first selected option in this select tag (or the currently selected option in a
* normal select)
*/
public WebElement getFirstSelectedOption() {
for (WebElement option : getOptions()) {
if (option.isSelected()) {
return option;
}
}
throw new NoSuchElementException("No options are selected");
}
代码示例来源:origin: org.openqa.selenium.webdriver/webdriver-support
/**
* @return The first selected option in this select tag (or the currently selected option in a
* normal select)
*/
public WebElement getFirstSelectedOption() {
for (WebElement option : getOptions()) {
if (option.isSelected()) {
return option;
}
}
throw new NoSuchElementException("No options are selected");
}
代码示例来源:origin: com.github.webdriverextensions/webdriverextensions
public static boolean optionIsEnabled(String text, WebElement webElement) {
List<WebElement> options = new Select(webElement).getOptions();
for (WebElement option : options) {
if (textEquals(text, option) && isEnabled(option)) {
return true;
}
}
return false;
}
代码示例来源:origin: com.github.webdriverextensions/webdriverextensions
public static boolean optionIsDisabled(String text, WebElement webElement) {
List<WebElement> options = new Select(webElement).getOptions();
for (WebElement option : options) {
if (textEquals(text, option) && isDisabled(option)) {
return true;
}
}
return false;
}
代码示例来源:origin: com.github.webdriverextensions/webdriverextensions
public static boolean optionIsDeselected(String text, WebElement webElement) {
List<WebElement> options = new Select(webElement).getOptions();
for (WebElement option : options) {
if (textEquals(text, option) && isDeselected(option)) {
return true;
}
}
return false;
}
代码示例来源:origin: webdriverextensions/webdriverextensions
public static boolean optionIsEnabled(String text, WebElement webElement) {
List<WebElement> options = new Select(webElement).getOptions();
for (WebElement option : options) {
if (textEquals(text, option) && isEnabled(option)) {
return true;
}
}
return false;
}
代码示例来源:origin: webdriverextensions/webdriverextensions
public static boolean optionIsDisabled(String text, WebElement webElement) {
List<WebElement> options = new Select(webElement).getOptions();
for (WebElement option : options) {
if (textEquals(text, option) && isDisabled(option)) {
return true;
}
}
return false;
}
代码示例来源:origin: Wikia/selenium-tests
public String moveThread() {
clickOnMoreButton();
clickOnMoveThreadButton();
wait.forElementVisible(moveThreadModalSelectElement);
Select dropList = new Select(moveThreadModalSelectElement);
String selectedItem = dropList.getOptions().get(1).getText();
dropList.selectByIndex(1);
wait.forElementClickable(moveThreadModalMoveThreadButton);
scrollAndClick(moveThreadModalMoveThreadButton);
Log.log("moveThread", "thread moved to the following board: " + selectedItem, true, driver);
return selectedItem;
}
内容来源于网络,如有侵权,请联系作者删除!