本文整理了Java中org.openqa.selenium.support.ui.Select.selectByValue()
方法的一些代码示例,展示了Select.selectByValue()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Select.selectByValue()
方法的具体详情如下:
包路径:org.openqa.selenium.support.ui.Select
类名称:Select
方法名:selectByValue
[英]Select all options that have a value matching the argument. That is, when given "foo" this would select an option like: <option value="foo">Bar</option>
[中]选择所有值与参数匹配的选项。也就是说,当给定“foo”时,这将选择一个选项,如:<option value=“foo”>Bar</option>
代码示例来源:origin: selenide/selenide
private void selectOptionByValue(WebElementSource selectField, Select select, String value) {
try {
select.selectByValue(value);
}
catch (NoSuchElementException e) {
throw new ElementNotFound(selectField.driver(), selectField.getSearchCriteria() + "/option[value:" + value + ']', exist, e);
}
}
}
代码示例来源:origin: TEAMMATES/teammates
/**
* Selects student nationality from the dropdown list if the nationality is
* valid, otherwise it fails with a message.
*/
public void selectNationality(String studentNationality) {
if (NationalityHelper.getNationalities().contains(studentNationality) || "".equals(studentNationality)) {
Select dropdown = new Select(studentNationalityDropdown);
dropdown.selectByValue(studentNationality);
} else {
fail("Given nationality " + studentNationality + " is not valid!");
}
}
代码示例来源:origin: TEAMMATES/teammates
/**
* Selects the option by value and returns whether the dropdown value has changed.
*
* @throws AssertionError if the selected option is not the one we wanted to select
*
* @see Select#selectByValue(String)
*/
boolean selectDropdownByActualValue(WebElement element, String value) {
Select select = new Select(element);
WebElement originalSelectedOption = select.getFirstSelectedOption();
select.selectByValue(value);
WebElement newSelectedOption = select.getFirstSelectedOption();
assertEquals(value, newSelectedOption.getAttribute("value"));
return !newSelectedOption.equals(originalSelectedOption);
}
代码示例来源:origin: org.xwiki.platform/xwiki-platform-test-ui
@Override
public void selectByValue(String value)
{
super.selectByValue(value);
maybeCloseDropDownList();
}
代码示例来源:origin: yandex-qatools/htmlelements
/**
* Select all options that have a value matching the argument. That is, when given "foo" this
* would select an option like:
* <p/>
* <option value="foo">Bar</option>
*
* @param value The value to match against
*/
public void selectByValue(String value) {
getSelect().selectByValue(value);
}
代码示例来源:origin: stackoverflow.com
WebDriverWait wait = new WebDriverWait(driver, 100);
By selectElementSelector = By.xpath("//select[contains(@id,'TaskId')]");
WebElement selectElement = wait.until(ExpectedConditions.presenceOfElementLocated(selectElementSelector));
Select dropdown = new Select (selectElement);
dropdown.selectByValue("OPT2");
代码示例来源:origin: ru.sbtqa.htmlelements/htmlelements-java
/**
* Select all options that have a value matching the argument. That is, when given "foo" this
* would select an option like:
*
* <option value="foo">Bar</option>
*
* @param value The value to match against
*/
public void selectByValue(String value) {
getSelect().selectByValue(value);
}
代码示例来源:origin: ru.yandex.qatools.htmlelements/htmlelements-java
/**
* Select all options that have a value matching the argument. That is, when given "foo" this
* would select an option like:
* <p/>
* <option value="foo">Bar</option>
*
* @param value The value to match against
*/
public void selectByValue(String value) {
getSelect().selectByValue(value);
}
代码示例来源:origin: com.github.wiselenium/wiselenium-core
@Override
public Select selectByValue(String value) {
this.getWrappedSelect().selectByValue(value);
return this;
}
代码示例来源:origin: org.xwiki.platform/xwiki-platform-test-ui
/**
* @since 3.2M3
*/
public void setSyntaxId(String syntaxId)
{
Select select = new Select(this.syntaxIdSelect);
select.selectByValue(syntaxId);
}
代码示例来源:origin: com.github.wiselenium/wiselenium-elements
@Override
public MultiSelect selectByValue(String... values) {
for (String v : values)
this.getWrappedSelect().selectByValue(v);
return this;
}
代码示例来源:origin: com.github.wiselenium/wiselenium-core
@Override
public MultiSelect selectByValue(String... values) {
for (String v : values)
this.getWrappedSelect().selectByValue(v);
return this;
}
代码示例来源:origin: org.xwiki.platform/xwiki-platform-test-ui
public void setFieldValue(WebElement fieldElement, String value)
{
if ("checkbox".equals(fieldElement.getAttribute("type"))) {
setCheckBox(fieldElement, value.equals("true"));
} else if ("select".equals(fieldElement.getTagName())) {
Select select = new Select(fieldElement);
select.selectByValue(value);
} else {
fieldElement.clear();
fieldElement.sendKeys(value);
}
}
代码示例来源:origin: com.synaptix.redpepper/redpepper-automation
@Override
public void selectByValue(String value) {
WebElement find = frontEndDriver.find(wrappedElement);
Select realSelect = new Select(find);
realSelect.selectByValue(value);
}
代码示例来源:origin: epam/JDI
public void selectOptionByValue(String... values) {
Select selectField = new Select(getWebElement());
for (String value: values) {
selectField.selectByValue(value);
}
}
代码示例来源:origin: stackoverflow.com
Select select = new Select(driver.findElemetn(/*Way to your drop down*/));
select.selectByValue("your value")
//or
select.selectByVisibleText("your Test");
//alternativly you can do something like this
List<WebElement> options = select.getOptions();
//find your desired option
select.selectByVisibleText(option.getText());
代码示例来源:origin: net.thucydides/thucydides-core
@Override
public WebElementFacade selectByValue(String value) {
logIfVerbose("Select value '" + value + "'");
enableHighlightingIfRequired();
waitUntilElementAvailable();
Select select = new Select(getElement());
select.selectByValue(value);
notifyScreenChange();
return this;
}
代码示例来源:origin: net.serenity-bdd/core
@Override
public WebElementFacade selectByValue(String value) {
logIfVerbose("Select value '" + value + "'");
enableHighlightingIfRequired();
waitUntilElementAvailable();
Select select = new Select(getElement());
select.selectByValue(value);
notifyScreenChange();
return this;
}
代码示例来源:origin: Wikia/selenium-tests
public void adjustPosition(PositionsGallery positionGallery) {
wait.forElementVisible(position);
Select positionDropdown = new Select(position);
positionDropdown.selectByValue(positionGallery.getPositionGallery());
}
代码示例来源:origin: Wikia/selenium-tests
public void adjustSpacing(SpacingGallery spacingGallery) {
wait.forElementVisible(spacing);
Select spacingDropdown = new Select(spacing);
spacingDropdown.selectByValue(spacingGallery.getSpacingGallery());
}
内容来源于网络,如有侵权,请联系作者删除!