本文整理匯總了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;
}
示例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() + ")");
}
示例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);
}
}
示例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;
}
示例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;
}
示例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");
}