Java Code Examples for org.openqa.selenium.support.ui.Select#selectByVisibleText()

The following examples show how to use org.openqa.selenium.support.ui.Select#selectByVisibleText() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PortalMarketServiceWT.java    From development with Apache License 2.0 6 votes vote down vote up
@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());

}
 
Example 2
Source File: ClientScopesSetupForm.java    From keycloak with Apache License 2.0 6 votes vote down vote up
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();
        }
    }
}
 
Example 3
Source File: InterpreterIT.java    From zeppelin with Apache License 2.0 6 votes vote down vote up
@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);
  }
}
 
Example 4
Source File: InstructorFeedbackResultsPage.java    From teammates with GNU General Public License v2.0 5 votes vote down vote up
public void filterResponsesForAllSections() {
    displayEditSettingsWindow();

    Select select = new Select(browser.driver.findElements(By.name(Const.ParamsNames.FEEDBACK_RESULTS_GROUPBYSECTION))
                                             .get(1));
    select.selectByVisibleText("All");

    submitEditForm();
}
 
Example 5
Source File: ParagraphActionsIT.java    From zeppelin with Apache License 2.0 5 votes vote down vote up
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);
  }
}
 
Example 6
Source File: ToolBarController.java    From mycore with GNU General Public License v3.0 5 votes vote down vote up
/**
 * 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);
}
 
Example 7
Source File: TrAddPage.java    From oxTrust with MIT License 5 votes vote down vote up
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();
}
 
Example 8
Source File: CargoDestinationPage.java    From dddsample-core with MIT License 5 votes vote down vote up
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);
}
 
Example 9
Source File: EventSimulatorTestCase.java    From product-cep with Apache License 2.0 5 votes vote down vote up
@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();
}
 
Example 10
Source File: SelectListOption.java    From opentest with MIT License 5 votes vote down vote up
@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.");
    }

}
 
Example 11
Source File: InstructorFeedbackResultsPage.java    From teammates with GNU General Public License v2.0 5 votes vote down vote up
public void displayByQuestion() {
    displayEditSettingsWindow();

    Select select = new Select(browser.driver.findElement(By.name(Const.ParamsNames.FEEDBACK_RESULTS_SORTTYPE)));
    select.selectByVisibleText("Group by - Question");

    submitEditForm();
}
 
Example 12
Source File: IssuesColumnConfiguration.java    From warnings-ng-plugin with MIT License 5 votes vote down vote up
/**
 * 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());
}
 
Example 13
Source File: IosEncapsulateOperation.java    From LuckyFrameClient with GNU Affero General Public License v3.0 5 votes vote down vote up
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;
}
 
Example 14
Source File: ProfilePage.java    From che with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * 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());
}
 
Example 15
Source File: FeedbackSubmitPage.java    From teammates with GNU General Public License v2.0 4 votes vote down vote up
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);
}
 
Example 16
Source File: ClientAddPage.java    From oxTrust with MIT License 4 votes vote down vote up
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);
}
 
Example 17
Source File: UserAddPage.java    From oxTrust with MIT License 4 votes vote down vote up
public void fillStatus(String status) {
	WebElement element = webDriver.findElement(By.className("Status"));
	Select select = new Select(element);
	select.selectByVisibleText(status);
}
 
Example 18
Source File: DefaultAuthenMethodPage.java    From oxTrust with MIT License 4 votes vote down vote up
public void setDefaultAcr(String defaultAcr) {
	Select select = new Select(webDriver.findElement(By.className("defaultAcrSelectBox")));
	select.selectByVisibleText(defaultAcr);
}
 
Example 19
Source File: ClientAddPage.java    From oxTrust with MIT License 4 votes vote down vote up
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);
}
 
Example 20
Source File: ExplicitWait.java    From sonar-webdriver-plugin with MIT License 4 votes vote down vote up
public void select(String inputText, By locator) {
    Select selectItem = new Select(find(locator));
    selectItem.selectByVisibleText(inputText);
}