下面列出了org.openqa.selenium.support.ui.Select#selectByVisibleText ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
@Test
public void testShowDescriptionOnInterpreterCreate() throws Exception {
try {
// navigate to interpreter page
WebElement settingButton = driver.findElement(By.xpath("//button[@class='nav-btn dropdown-toggle ng-scope']"));
settingButton.click();
WebElement interpreterLink = driver.findElement(By.xpath("//a[@href='#/interpreter']"));
interpreterLink.click();
WebElement createButton = driver.findElement(By.xpath("//button[contains(., 'Create')]"));
createButton.click();
Select select = new Select(driver.findElement(By.xpath("//select[@ng-change='newInterpreterGroupChange()']")));
select.selectByVisibleText("spark");
collector.checkThat("description of interpreter property is displayed",
driver.findElement(By.xpath("//tr/td[contains(text(), 'spark.app.name')]/following-sibling::td[2]")).getText(),
CoreMatchers.equalTo("The name of spark application."));
} catch (Exception e) {
handleException("Exception in InterpreterIT while testShowDescriptionOnInterpreterCreate ", e);
}
}
static void addMissingScopes(Select select, WebElement button, Collection<String> scopes) {
select.deselectAll();
if (scopes != null) { // if scopes not provided, don't add any
boolean someAdded = false;
for (String scope : getSelectValues(select)) {
if (scopes.contains(scope)) { // if scopes provided, add only the missing
select.selectByVisibleText(scope);
someAdded = true;
}
}
if (someAdded) {
waitUntilElement(button).is().enabled();
button.click();
}
}
}
@Test
public void test02definePreisModel() throws Exception {
tester.visitPortal(PortalPathSegments.DEFINE_PREICEMODEL);
Select dropdownServiceName = new Select(tester.getDriver().findElement(
By.id(PortalHtmlElements.DEFINE_PRICEMODEL_DROPDOWN_SERVICENAME)));
dropdownServiceName
.selectByVisibleText(PlaygroundSuiteTest.marketServiceName);
tester.waitForElementVisible(
By.id(PortalHtmlElements.DEFINE_PRICEMODEL_BUTTON_SAVE), 10);
if (!tester.getDriver().findElement(By.id(
PortalHtmlElements.DEFINE_PRICEMODEL_CHECKBOX_FREE_OF_CHARGE))
.isSelected()) {
tester.clickElement(
PortalHtmlElements.DEFINE_PRICEMODEL_CHECKBOX_FREE_OF_CHARGE);
}
tester.waitForElementVisible(
By.id(PortalHtmlElements.DEFINE_PRICEMODEL_BUTTON_SAVE), 10);
tester.clickElement(PortalHtmlElements.DEFINE_PRICEMODEL_BUTTON_SAVE);
assertTrue(tester.getExecutionResult());
}
@Test(groups = "wso2.cep", description = "Test CSRF issue in event simulator")
public void testCSRF() throws Exception {
boolean testPassed = false;
// Login
driver.get(getLoginURL());
driver.findElement(By.id("txtUserName")).clear();
driver.findElement(By.id("txtUserName")).sendKeys(cepServer.getContextTenant().getContextUser().getUserName());
driver.findElement(By.id("txtPassword")).clear();
driver.findElement(By.id("txtPassword")).sendKeys(cepServer.getContextTenant().getContextUser().getPassword());
driver.findElement(By.cssSelector("input.button")).click();
driver.findElement(By.id("menu-panel-button4")).click();
// Goto Event Simulator page
String pageUrl = backendURL.substring(0, 22) + "/carbon/eventsimulator/index.jsp?";
List<NameValuePair> pageParams = new ArrayList<>();
pageParams.add(new BasicNameValuePair("region", "5"));
pageParams.add(new BasicNameValuePair("item", "event_simulator_menu"));
pageUrl += URLEncodedUtils.format(pageParams, "UTF-8");
driver.get(pageUrl);
// Fill the event field values and click send
Select dropdown = new Select(driver.findElement(By.id("EventStreamID")));
dropdown.selectByVisibleText("TempStream:1.0.0");
driver.findElement(By.id("0")).clear();
driver.findElement(By.id("0")).sendKeys("11");
driver.findElement(By.id("1")).clear();
driver.findElement(By.id("1")).sendKeys("22");
driver.findElement(By.id("2")).clear();
driver.findElement(By.id("2")).sendKeys("33");
driver.findElement(By.xpath("(//input[@value='Send'])[1]")).click();
if("Events is successfully sent".equals(
driver.findElement(By.id("messagebox-info")).findElement(By.tagName("p")).getText())) {
testPassed = true;
}
Assert.assertTrue(testPassed);
driver.close();
}
/**
* select role for the profile
*
* @param role
*/
public void selectRole(Role role) {
Select select =
new Select(
new WebDriverWait(seleniumWebDriver, LOAD_PAGE_TIMEOUT_SEC)
.until(ExpectedConditions.visibilityOf(roleSelect)));
select.selectByVisibleText(role.getRole());
}
public static String selectOperation(IOSElement ie, String operation, String operationValue) {
String result = "";
// �����������
Select select = new Select(ie);
// �����������¼�
switch (operation) {
case "selectbyvisibletext":
select.selectByVisibleText(operationValue);
LogUtil.APP
.info("���������ͨ��VisibleText����ѡ��...��VisibleText����ֵ:{}��",operationValue);
break;
case "selectbyvalue":
select.selectByValue(operationValue);
LogUtil.APP.info("���������ͨ��Value����ѡ��...��Value����ֵ:{}��",operationValue);
break;
case "selectbyindex":
select.selectByIndex(Integer.parseInt(operationValue));
LogUtil.APP.info("���������ͨ��Index����ѡ��...��Index����ֵ:{}��",operationValue);
break;
case "isselect":
result = "��ȡ����ֵ�ǡ�" + ie.isSelected() + "��";
LogUtil.APP.info("�ж϶����Ƿ��Ѿ���ѡ��...�����ֵ:{}��",ie.isSelected());
break;
default:
break;
}
return result;
}
/**
* selects a type from the "Type"-dropdown
*
* @param statisticProperty Property object holding the display name
*/
public void selectType(final StatisticProperties statisticProperty) {
// scroll to bottom of page to ensure visibility of dropdown
JavascriptExecutor js = ((JavascriptExecutor) driver);
js.executeScript("window.scrollTo(0, document.body.scrollHeight)");
Select typeSelect = new Select(driver.findElement(By.name("_.type")));
typeSelect.selectByVisibleText(statisticProperty.getDisplayName());
}
public void displayByQuestion() {
displayEditSettingsWindow();
Select select = new Select(browser.driver.findElement(By.name(Const.ParamsNames.FEEDBACK_RESULTS_SORTTYPE)));
select.selectByVisibleText("Group by - Question");
submitEditForm();
}
@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 optionNumber.");
}
}
public void filterResponsesForAllSections() {
displayEditSettingsWindow();
Select select = new Select(browser.driver.findElements(By.name(Const.ParamsNames.FEEDBACK_RESULTS_GROUPBYSECTION))
.get(1));
select.selectByVisibleText("All");
submitEditForm();
}
public CargoDetailsPage selectDestinationTo(String destination) {
WebElement destinationPicker = driver.findElement(By.name("unlocode"));
Select select = new Select(destinationPicker);
select.selectByVisibleText(destination);
destinationPicker.submit();
return new CargoDetailsPage(driver);
}
public void selectId(String value) {
WebElement link = webDriver
.findElement(By.id("trustForm:spMetaDataSourceTypeFederationEntitySelection:outputInputPanel"));
link.findElement(By.tagName("a")).click();
fluentWait(ONE_SEC);
WebElement main = webDriver.findElement(By.id("entityIdSelector_content"));
WebElement select = main.findElement(By.tagName("select"));
Select selectBox = new Select(select);
selectBox.selectByVisibleText(value);
main.findElement(By.id("EntityIdUpdate")).findElement(By.tagName("input")).click();
}
/**
* selects the first picture with the label <b>orderLabel</b> in the selectbox
*
* @param orderLabel
*/
public void selectPictureWithOrder(String orderLabel) {
By selector = By.cssSelector(SELECTBOX_SELECTOR);
WebElement element = this.getDriver().findElement(selector);
Select select = new Select(element);
select.selectByVisibleText(orderLabel);
}
public void testMultipleDynamicFormsSameType() throws Exception {
try {
createNewNote();
setTextOfParagraph(1, "%spark println(\"Howdy \"+z.select(\"fruits\", Seq((\"1\",\"Apple\")," +
"(\"2\",\"Orange\"),(\"3\",\"Peach\")))); println(\"Howdy \"+z.select(\"planets\", " +
"Seq((\"1\",\"Venus\"),(\"2\",\"Earth\"),(\"3\",\"Mars\"))))");
runParagraph(1);
waitForParagraph(1, "FINISHED");
collector.checkThat("Output text should not display any of the options in select form",
driver.findElement(By.xpath(getParagraphXPath(1) + "//div[contains(@class, 'text plainTextContent')]")).getText(),
CoreMatchers.equalTo("Howdy 1\nHowdy 1"));
Select dropDownMenu = new Select(driver.findElement(By.xpath("(" + (getParagraphXPath(1) + "//select)[1]"))));
dropDownMenu.selectByVisibleText("Apple");
collector.checkThat("After selection in drop down menu, output should display the new option we selected",
driver.findElement(By.xpath(getParagraphXPath(1) + "//div[contains(@class, 'text plainTextContent')]")).getText(),
CoreMatchers.equalTo("Howdy 1\nHowdy 1"));
driver.findElement(By.xpath(getParagraphXPath(1) + "//span[@class='icon-settings']")).click();
clickAndWait(By.xpath(getParagraphXPath(1) + "//ul/li/form/input[contains(@ng-checked, 'true')]"));
Select sameDropDownMenu = new Select(driver.findElement(By.xpath("(" + (getParagraphXPath(1) + "//select)[2]"))));
sameDropDownMenu.selectByVisibleText("Earth");
waitForParagraph(1, "FINISHED");
collector.checkThat("After 'Run on selection change' checkbox is unchecked, the paragraph should not run if selecting a different option",
driver.findElement(By.xpath(getParagraphXPath(1) + "//div[contains(@class, 'text plainTextContent')]")).getText(),
CoreMatchers.equalTo("Howdy 1\nHowdy 1"));
deleteTestNotebook(driver);
} catch (Exception e) {
handleException("Exception in ParagraphActionsIT while testMultipleDynamicFormsSameType ", e);
}
}
public void select(String inputText, By locator) {
Select selectItem = new Select(find(locator));
selectItem.selectByVisibleText(inputText);
}
public void setType(String type) {
WebElement main = webDriver.findElement(By.className(BOX_HEADER));
WebElement selectBox = main.findElement(By.className("applicationTypeSelectBox"));
Select select = new Select(selectBox);
select.selectByVisibleText(type);
}
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);
}
public void fillStatus(String status) {
WebElement element = webDriver.findElement(By.className("Status"));
Select select = new Select(element);
select.selectByVisibleText(status);
}
public void setDefaultAcr(String defaultAcr) {
Select select = new Select(webDriver.findElement(By.className("defaultAcrSelectBox")));
select.selectByVisibleText(defaultAcr);
}
public void setSubjectType(String value) {
WebElement main = webDriver.findElement(By.className(BOX_HEADER));
WebElement selectBox = main.findElement(By.className("subjectTypeSelectBox"));
Select select = new Select(selectBox);
select.selectByVisibleText(value);
}