本文整理匯總了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);
}