本文整理了Java中org.openqa.selenium.support.ui.Select.selectByVisibleText()
方法的一些代码示例,展示了Select.selectByVisibleText()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Select.selectByVisibleText()
方法的具体详情如下:
包路径:org.openqa.selenium.support.ui.Select
类名称:Select
方法名:selectByVisibleText
[英]Select all options that display text matching the argument. That is, when given "Bar" this would select an option like: <option value="foo">Bar</option>
[中]选择显示与参数匹配的文本的所有选项。也就是说,当给定“Bar”时,这将选择一个选项,如:<option value=“foo”>Bar</option>
代码示例来源:origin: stackoverflow.com
Select select = new Select(driver.findElement(By.xpath("//path_to_drop_down")));
select.deselectAll();
select.selectByVisibleText("Value1");
代码示例来源:origin: selenide/selenide
private void selectOptionsByTexts(WebElementSource selectField, String[] texts) {
Select select = new Select(selectField.getWebElement());
for (String text : texts) {
try {
select.selectByVisibleText(text);
}
catch (NoSuchElementException e) {
throw new ElementNotFound(selectField.driver(), selectField.getSearchCriteria() + "/option[text:" + text + ']', exist, e);
}
}
}
代码示例来源:origin: TEAMMATES/teammates
public void selectResponseTextDropdown(int qnNumber, int responseNumber, int responseSubNumber, String text) {
WebElement element = browser.driver.findElement(
By.id(Const.ParamsNames.FEEDBACK_RESPONSE_TEXT + "-"
+ qnNumber + "-" + responseNumber
+ "-" + responseSubNumber));
Select dropdown = new Select(element);
dropdown.selectByVisibleText(text);
}
代码示例来源:origin: TEAMMATES/teammates
public void selectRecipient(int qnNumber, int responseNumber, String recipientName) {
Select selectElement = new Select(browser.driver.findElement(
By.name(Const.ParamsNames.FEEDBACK_RESPONSE_RECIPIENT + "-" + qnNumber + "-" + responseNumber)));
selectElement.selectByVisibleText(recipientName);
}
代码示例来源:origin: TEAMMATES/teammates
/**
* Selects the option by visible text and returns whether the dropdown value has changed.
*
* @throws AssertionError if the selected option is not the one we wanted to select
*
* @see Select#selectByVisibleText(String)
*/
boolean selectDropdownByVisibleValue(WebElement element, String text) {
Select select = new Select(element);
WebElement originalSelectedOption = select.getFirstSelectedOption();
select.selectByVisibleText(text);
WebElement newSelectedOption = select.getFirstSelectedOption();
assertEquals(text, newSelectedOption.getText().trim());
return !newSelectedOption.equals(originalSelectedOption);
}
代码示例来源:origin: TEAMMATES/teammates
public void displayByGiverQuestionRecipient() {
displayEditSettingsWindow();
Select select = new Select(browser.driver.findElement(By.name(Const.ParamsNames.FEEDBACK_RESULTS_SORTTYPE)));
select.selectByVisibleText("Group by - Giver > Question > Recipient");
submitEditForm();
}
代码示例来源:origin: TEAMMATES/teammates
public void displayByRecipientQuestionGiver() {
displayEditSettingsWindow();
Select select = new Select(browser.driver.findElement(By.name(Const.ParamsNames.FEEDBACK_RESULTS_SORTTYPE)));
select.selectByVisibleText("Group by - Recipient > Question > Giver");
submitEditForm();
}
代码示例来源:origin: TEAMMATES/teammates
public void displayByRecipientGiverQuestion() {
displayEditSettingsWindow();
Select select = new Select(browser.driver.findElement(By.name(Const.ParamsNames.FEEDBACK_RESULTS_SORTTYPE)));
select.selectByVisibleText("Group by - Recipient > Giver > Question");
submitEditForm();
}
代码示例来源:origin: TEAMMATES/teammates
public void displayByQuestion() {
displayEditSettingsWindow();
Select select = new Select(browser.driver.findElement(By.name(Const.ParamsNames.FEEDBACK_RESULTS_SORTTYPE)));
select.selectByVisibleText("Group by - Question");
submitEditForm();
}
代码示例来源:origin: TEAMMATES/teammates
public void displayByGiverRecipientQuestion() {
displayEditSettingsWindow();
Select select = new Select(browser.driver.findElement(By.name(Const.ParamsNames.FEEDBACK_RESULTS_SORTTYPE)));
select.selectByVisibleText("Group by - Giver > Recipient > Question");
submitEditForm();
}
代码示例来源:origin: TEAMMATES/teammates
public void filterResponsesForSection(String section) {
displayEditSettingsWindow();
Select select = new Select(browser.driver.findElements(By.name(Const.ParamsNames.FEEDBACK_RESULTS_GROUPBYSECTION))
.get(1));
select.selectByVisibleText(section);
submitEditForm();
}
代码示例来源:origin: TEAMMATES/teammates
public void filterResponsesForAllSections() {
displayEditSettingsWindow();
Select select = new Select(browser.driver.findElements(By.name(Const.ParamsNames.FEEDBACK_RESULTS_GROUPBYSECTION))
.get(1));
select.selectByVisibleText("All");
submitEditForm();
}
代码示例来源:origin: stackoverflow.com
WebDriverWait wait = new WebDriverWait(driver, 300);
WebElement triggerDropDown = driver.findElement(By
.className("ui-helper-hidden"));
triggerDropDown.click();
WebElement selectElement = wait.until(ExpectedConditions
.visibilityOfElementLocated(By.id("formLevel:levels_input")));
Select select = new Select(selectElement);
select.selectByVisibleText("SECURITY");
代码示例来源:origin: stackoverflow.com
Select sele = new Select(driver.findElement(By.id("select_category")));
//Select the dropdown by using the displayed value.
sele.selectByVisibleText(`displayed value`);
//or you can Select the dropdown by using the index value.
sele.selectByIndex(`index value`);
//or you can Select the dropdown by using the value attribute.
sele.selectByIndex(`value in the value attribute`);
代码示例来源:origin: org.xwiki.platform/xwiki-platform-test-ui
@Override
public void selectByVisibleText(String text)
{
super.selectByVisibleText(text);
maybeCloseDropDownList();
}
代码示例来源:origin: com.atlassian.jira/atlassian-jira-pageobjects
public void selectPermission(String permission)
{
if (permissionSelector == null)
{
permissionSelector = new Select(driver.findElement(By.className("fieldValueArea")));
}
permissionSelector.selectByVisibleText(permission);
}
代码示例来源:origin: org.xwiki.platform/xwiki-platform-test-ui
/**
* Selects the specified hour.
*
* @param hour the hour to select
* @return this data picker
*/
public DatePicker setHour(String hour)
{
Select hourSelector = new Select(container.findElement(By.className("hour")));
hourSelector.selectByVisibleText(hour);
return this;
}
代码示例来源:origin: net.thucydides/thucydides-core
@Override
public WebElementFacade selectByVisibleText(final String label) {
logIfVerbose("Select label '" + label + "'");
waitUntilElementAvailable();
Select select = new Select(getElement());
select.selectByVisibleText(label);
notifyScreenChange();
return this;
}
代码示例来源:origin: net.serenity-bdd/serenity-core
public WebElementFacade byVisibleText(String label) {
if (webElementFacade.driverIsDisabled()) { return webElementFacade; }
webElementFacade.waitUntilElementAvailable();
Select select = new Select(webElementFacade.getElement());
select.selectByVisibleText(label);
webElementFacade.notifyScreenChange();
return webElementFacade;
}
代码示例来源:origin: qaprosoft/carina
@Override
public boolean doSelect(String text) {
final String decryptedSelectText = cryptoTool.decryptByPattern(text, CRYPTO_PATTERN);
DriverListener.setMessages(Messager.SELECT_BY_TEXT_PERFORMED.getMessage(decryptedSelectText, getName()),
Messager.SELECT_BY_TEXT_NOT_PERFORMED.getMessage(decryptedSelectText, getNameWithLocator()));
final Select s = new Select(element);
// [VD] do not use selectByValue as modern controls could have only visible value without value
s.selectByVisibleText(decryptedSelectText);
return true;
}
内容来源于网络,如有侵权,请联系作者删除!