当前位置: 首页>>代码示例>>Java>>正文


Java Select.getOptions方法代码示例

本文整理汇总了Java中org.openqa.selenium.support.ui.Select.getOptions方法的典型用法代码示例。如果您正苦于以下问题:Java Select.getOptions方法的具体用法?Java Select.getOptions怎么用?Java Select.getOptions使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.openqa.selenium.support.ui.Select的用法示例。


在下文中一共展示了Select.getOptions方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: randomSelect

import org.openqa.selenium.support.ui.Select; //导入方法依赖的package包/类
@Override
public WebElement randomSelect(Element ele)
{
	Select select = createSelect(ele);
	if(select != null)
	{
		List<WebElement> options = select.getOptions();
		if(CollectionUtils.isNotEmpty(options))
		{
			int count = options.size();
			int index = RandomUtils.nextInt(count);
			index = (index == 0 ? 1 : index); //通常第一个选项都是无效的选项

			select.selectByIndex(index);
			
			return options.get(index);
		}
	}
	
	return null;
}
 
开发者ID:LinuxSuRen,项目名称:phoenix.webui.framework,代码行数:22,代码来源:SeleniumSelect.java

示例2: unsetValue

import org.openqa.selenium.support.ui.Select; //导入方法依赖的package包/类
/**
 * unselect a value
 *
 * @param value the value to unselect
 */
@Override
@PublicAtsApi
public void unsetValue(
                        String value ) {

    new RealHtmlElementState(this).waitToBecomeExisting();

    WebElement element = RealHtmlElementLocator.findElement(this);
    Select select = new Select(element);
    // select.deselectByVisibleText( value ); // this method doesn't throw an exception if the option doesn't exist
    for (WebElement option : select.getOptions()) {
        if (option.getText().equals(value)) {
            if (option.isSelected()) {
                option.click();
                UiEngineUtilities.sleep();
            }
            return;
        }
    }
    throw new SeleniumOperationException("Option with label '" + value + "' not found. ("
                                         + this.toString() + ")");
}
 
开发者ID:Axway,项目名称:ats-framework,代码行数:28,代码来源:RealHtmlMultiSelectList.java

示例3: assertSelectContains

import org.openqa.selenium.support.ui.Select; //导入方法依赖的package包/类
@Action(object = ObjectType.SELENIUM,
        desc = "Assert if the  select list [<Object>] contains [<Data>]",
        input = InputType.YES)
public void assertSelectContains() {
    if (elementPresent()) {
        Boolean isPresent = false;
        Select select = new Select(Element);
        for (WebElement option : select.getOptions()) {
            if (option.getText().trim().equals(Data)) {
                isPresent = true;
                break;
            }
        }
        if (isPresent) {
            Report.updateTestLog(Action, ObjectName + " Contains the Option " + Data, Status.DONE);
        } else {
            Report.updateTestLog(Action, ObjectName + " doesn't Contains the Option " + Data, Status.DEBUG);
        }
    } else {
        throw new ElementException(ElementException.ExceptionType.Element_Not_Found, ObjectName);
    }
}
 
开发者ID:CognizantQAHub,项目名称:Cognizant-Intelligent-Test-Scripter,代码行数:23,代码来源:Dropdown.java

示例4: getAllListOptions

import org.openqa.selenium.support.ui.Select; //导入方法依赖的package包/类
public List<String> getAllListOptions(String locator) {
    List<String> optionValues = new ArrayList<String>();
    Select menuList = getSelectObject(locator);
    List<WebElement> options = menuList.getOptions();
    for (WebElement option : options) {
        optionValues.add(option.getText());
    }
    return optionValues;
}
 
开发者ID:hemano,项目名称:cucumber-framework-java,代码行数:10,代码来源:WebDriverWebController.java

示例5: findOptionByIgnoreCaseText

import org.openqa.selenium.support.ui.Select; //导入方法依赖的package包/类
public static int findOptionByIgnoreCaseText(String text, Select dropDown) {
    int index = 0;
    for (WebElement option : dropDown.getOptions()) {
        if (comparingNames(text, option.getText())) {
            return index;
        }
        index++;
    }
    return -1;
}
 
开发者ID:NoraUi,项目名称:NoraUi,代码行数:11,代码来源:NameUtilities.java

示例6: createAlarm

import org.openqa.selenium.support.ui.Select; //导入方法依赖的package包/类
@Before
public void createAlarm() {
    TestScenario.navigation.clickOnAddAlarm();
    //Enter alarm name
    WebElement name = driver.findElement(By.name("name"));
    name.sendKeys(NAME);
    LOGGER.info("Enter alarm name");

    //Enter alarm description
    WebElement description = driver.findElement(By.name("description"));
    description.sendKeys(DESCRIPTION);
    LOGGER.info("Enter alarm description");

    //enter alarm graphite key
    WebElement key = driver.findElement(By.name("graphite-key"));
    key.sendKeys(GRAPHITE_KEY);
    LOGGER.info("Enter alarm graphite key");

    //go to step 2
    Utils.clickWhenReady(driver, By.name("go-to-step-2"));
    LOGGER.info("go to step 2");

    //change windowMode
    Select windowModes = new Select(driver.findElement(By.id("windowMode")));
    List<WebElement> options = windowModes.getOptions();
    for(WebElement option: options){
        option.click();
        String value = option.getAttribute("value");
        if(value.equalsIgnoreCase("summarize")) {
            assertTrue(driver.findElement(By.id("windowAggregation")).isDisplayed());
            assertTrue(driver.findElement(By.id("timeUnitsNumber")).isDisplayed());
            assertTrue(driver.findElement(By.id("windowUnits")).isDisplayed());
        }
    }
    LOGGER.info("try all windowModes");


    //go to step 3
    Utils.clickWhenReady(driver, By.name("go-to-step-3"));
    LOGGER.info("go to step 3");

    //Enter warn Threshold
    WebElement warnThreshold = driver.findElement(By.name("warn-threshold"));
    warnThreshold.sendKeys(WARN_THRESHOLD);
    LOGGER.info("Enter warning threshold");

    //Enter error Threshold
    WebElement errorThreshold = driver.findElement(By.name("error-threshold"));
    errorThreshold.sendKeys(ERROR_THRESHOLD);
    LOGGER.info("Enter error threshold");

    //go to step 4
    Utils.clickWhenReady(driver, By.id("go-to-step-4"));
    LOGGER.info("Go to step 4");

    //go to step 5
    Utils.clickWhenReady(driver, By.id("go-to-step-5"));
    LOGGER.info("Go to step 5");

    //create alarm
    new WebDriverWait(driver,Utils.DEFAULT_WAITING_TIME).until(ExpectedConditions.visibilityOf(driver.findElement(By.id("confirm-alarm-creation"))));
    Utils.clickWhenReady(driver, By.id("confirm-alarm-creation"));

    //wait redirect
    new WebDriverWait(driver,Utils.DEFAULT_WAITING_TIME).until(ExpectedConditions.visibilityOfElementLocated(By.id("alarm-name-title")));
    LOGGER.info("alarm is created");
}
 
开发者ID:voyages-sncf-technologies,项目名称:cerebro,代码行数:68,代码来源:TestCreation.java


注:本文中的org.openqa.selenium.support.ui.Select.getOptions方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。