本文整理汇总了Java中org.openqa.selenium.support.ui.Select.selectByValue方法的典型用法代码示例。如果您正苦于以下问题:Java Select.selectByValue方法的具体用法?Java Select.selectByValue怎么用?Java Select.selectByValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.openqa.selenium.support.ui.Select
的用法示例。
在下文中一共展示了Select.selectByValue方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: selectByValue
import org.openqa.selenium.support.ui.Select; //导入方法依赖的package包/类
@Override
public boolean selectByValue(Element element, String value)
{
Select select = createSelect(element);
if(select != null)
{
select.selectByValue(value);
return true;
}
return false;
}
示例2: run
import org.openqa.selenium.support.ui.Select; //导入方法依赖的package包/类
@Override
public void run() {
super.run();
By locator = this.readLocatorArgument("locator");
String optionValue = this.readStringArgument("optionValue", null);
String optionText = this.readStringArgument("optionText", null);
Integer optionNumber = this.readIntArgument("optionNumber", null);
this.waitForAsyncCallsToFinish();
Select dropdownElement = new Select(this.getElement(locator));
if (optionValue != null) {
dropdownElement.selectByValue(optionValue);
} else if (optionText != null) {
dropdownElement.selectByVisibleText(optionText);
} else if (optionNumber != null) {
dropdownElement.selectByIndex(optionNumber - 1);
} else {
throw new RuntimeException(
"You must identify the option you want to select from the "
+ "list by providing one of the following arguments: "
+ "optionValue, optionText or optionIndex.");
}
}
示例3: selectOptionByValue
import org.openqa.selenium.support.ui.Select; //导入方法依赖的package包/类
/**
* Select option by value.
*
* @param element the element
* @param value the value
*/
public static void selectOptionByValue(WebElement element, String value) {
if (element != null) {
Select option = new Select(element);
if (option != null) {
option.selectByValue(value);
}
}
}
示例4: setDefaultServer
import org.openqa.selenium.support.ui.Select; //导入方法依赖的package包/类
public void setDefaultServer(String string) {
Select select = new Select(defaultServerSelect);
select.selectByValue(string);
}
示例5: selectPaginationDropDown
import org.openqa.selenium.support.ui.Select; //导入方法依赖的package包/类
@Then("^I select the dropdown of \"(.*)\" with option \"(.*)\"$")
public void selectPaginationDropDown(String component, String option) {
Select dropdownElement = new Select(jwalaUi.getWebDriver().findElement(By.xpath("//*[@id='" + component + "-config-datatable_length']/label/select")));
assertNotNull(dropdownElement);
dropdownElement.selectByValue(option);
}
示例6: selectByValue
import org.openqa.selenium.support.ui.Select; //导入方法依赖的package包/类
public void selectByValue(WebElement element, String value)
{
se = new Select(element);
se.selectByValue(value);
}
示例7: selectDropdown
import org.openqa.selenium.support.ui.Select; //导入方法依赖的package包/类
/**
* Selects in the dropdown (select) element with the given id the option
* with the given value.
*
* @param id
* the element id
* @param value
* the option value
* @throws NoSuchElementException
* if element is not present
*/
public void selectDropdown(String id, String value) {
Select select = new Select(driver.findElement(By.id(id)));
select.selectByValue(value);
}