org.openqa.selenium.support.ui.Select Java Examples

The following examples show how to use org.openqa.selenium.support.ui.Select. 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: ClientScopesSetupForm.java    From keycloak with Apache License 2.0 6 votes vote down vote up
static void removeRedundantScopes(Select select, WebElement button, Collection<String> scopes) {
    boolean someRemoved = false;

    select.deselectAll();
    for (String scope : getSelectValues(select)) {
        if (scopes == null // if scopes not provided, remove all
                || !scopes.contains(scope)) { // if scopes provided, remove only the redundant
            select.selectByVisibleText(scope);
            someRemoved = true;
        }
    }

    if (someRemoved) {
        waitUntilElement(button).is().enabled();
        button.click();
    }
}
 
Example #2
Source File: SeleniumSelect.java    From phoenix.webui.framework with Apache License 2.0 6 votes vote down vote up
@Override
public WebElement randomSelect(Element ele)
{
	Select select = createSelect(ele);
	if(select != null)
	{
		List<WebElement> options = select.getOptions();
		if(CollectionUtils.isNotEmpty(options))
		{
			int count = options.size();
			int index = RandomUtils.nextInt(count);
			index = (index == 0 ? 1 : index); //通常第一个选项都是无效的选项

			select.selectByIndex(index);
			
			return options.get(index);
		}
	}
	
	return null;
}
 
Example #3
Source File: AddExecutionPlanTestCase.java    From product-cep with Apache License 2.0 6 votes vote down vote up
@Test(groups = "wso2.cep", description = "verify adding an execution plan via management-console UI")
public void testAddExecutionPlan() throws Exception {
    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.linkText("Execution Plans")).click();
    driver.findElement(By.linkText("Add Execution Plan")).click();
    driver.findElement(By.cssSelector("option[value=\"inStream:1.0.0\"]")).click();
    driver.findElement(By.id("importedStreamAs")).clear();
    driver.findElement(By.id("importedStreamAs")).sendKeys("inStream");
    driver.findElement(By.cssSelector("input.button")).click();
    driver.findElement(By.xpath("//table[@id='eventProcessorAdd']/tbody/tr[2]/td/table/tbody/tr[4]/td/table/tbody/tr/td/div/div[6]/div/div/div/div/div[5]/div[11]/pre")).click();
    driver.findElement(By.id("exportedStreamValueOf")).clear();
    driver.findElement(By.id("exportedStreamValueOf")).sendKeys("outStream");
    new Select(driver.findElement(By.id("exportedStreamId"))).selectByVisibleText("outStream:1.0.0");
    driver.findElement(By.cssSelector("#exportedStreamId > option[value=\"outStream:1.0.0\"]")).click();
    driver.findElement(By.id("exportedStreamId")).click();
    new Select(driver.findElement(By.id("exportedStreamId"))).selectByVisibleText("outStream:1.0.0");
    driver.findElement(By.cssSelector("#exportedStreamId > option[value=\"outStream:1.0.0\"]")).click();
    driver.findElement(By.xpath("//input[@value='Export']")).click();
    driver.findElement(By.cssSelector("td.buttonRow > input[type=\"button\"]")).click();
    driver.close();
}
 
Example #4
Source File: Edition049_Holidays_2018.java    From appiumpro with Apache License 2.0 6 votes vote down vote up
@Test
public void testHolidayCheer() {
    driver.get(CHARITY_URL);
    wait.until(ExpectedConditions.presenceOfElementLocated(donationAmt)).sendKeys(DONATION_AMT);
    driver.findElement(donorEmail).sendKeys(EMAIL);
    driver.findElement(donorFirstName).sendKeys(FIRST_NAME);
    driver.findElement(donorLastName).sendKeys(LAST_NAME);
    driver.findElement(donorStreet).sendKeys(STREET);
    driver.findElement(donorCity).sendKeys(CITY);
    new Select(driver.findElement(donorCountry)).selectByValue(COUNTRY_CODE);
    new Select(driver.findElement(donorState)).selectByValue(STATE_CODE);
    driver.findElement(donorPostalCode).sendKeys(POSTAL_CODE);
    driver.findElement(donorPhone).sendKeys(PHONE);
    driver.findElement(donorCardName).sendKeys(CARD_NAME);
    driver.findElement(donorCardNumber).sendKeys(CARD_NUMBER);
    driver.findElement(donorCVV2).sendKeys(CVV2);
    new Select(driver.findElement(donorCardType)).selectByValue(CARD_TYPE);
    new Select(driver.findElement(donorCardMonth)).selectByValue(CARD_MONTH);
    new Select(driver.findElement(donorCardYear)).selectByValue(CARD_YEAR);
    driver.findElement(submitDonation).click();
}
 
Example #5
Source File: Test24.java    From h2o-2 with Apache License 2.0 6 votes vote down vote up
@Test
public void test24() throws Exception {
  driver.get(baseUrl + "/");
  driver.get(baseUrl + "/ImportUrl.html");
  driver.findElement(By.id("url")).clear();
  driver.findElement(By.id("url")).sendKeys("http://0.0.0.0:11185/datasets/iris.csv");
  driver.findElement(By.id("key")).clear();
  driver.findElement(By.id("key")).sendKeys("iris22.csv");
  driver.findElement(By.xpath("(//button[@onclick='query_submit()'])[2]")).click();
  driver.findElement(By.linkText("iris22.csv")).click();
  driver.findElement(By.linkText("Parse into hex format")).click();
  driver.findElement(By.cssSelector("button.btn.btn-primary")).click();
  driver.get(baseUrl + "/GBM.query?key=iris22.hex");
  driver.findElement(By.id("source")).clear();
  driver.findElement(By.id("source")).sendKeys("iris22.hex");
  driver.findElement(By.id("destination_key")).clear();
  driver.findElement(By.id("destination_key")).sendKeys("");
  new Select(driver.findElement(By.id("vresponse"))).selectByVisibleText("class");
  driver.findElement(By.xpath("(//button[@onclick='query_submit()'])[2]")).click();
}
 
Example #6
Source File: AssetUtil.java    From product-es with Apache License 2.0 6 votes vote down vote up
/**
 * Add a new asset
 *
 * @param driver      WebDriver instance
 * @param baseUrl     base url of the server
 * @param assetType   asset type
 * @param assetName   asset name
 * @param version     version
 */
public static void addNewAsset(WebDriver driver, String baseUrl, String assetType, String assetName, String version, String category, String url, String description) {
    driver.get(baseUrl + "/publisher/assets/" + assetType + "/list");
    WebDriverWait wait = new WebDriverWait(driver, MAX_POLL_COUNT);
    wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("Add"+assetType)));
    driver.findElement(By.id("Add"+assetType)).click();
    //driver.get(baseUrl+PUBLISHER_GADGET_CREATE_PAGE);
    driver.findElement(By.name("overview_name")).clear();
    driver.findElement(By.name("overview_name")).sendKeys(assetName);
    driver.findElement(By.name("overview_version")).clear();
    driver.findElement(By.name("overview_version")).sendKeys(version);
    if(!category.equals("")){
        new Select(driver.findElement(By.name("overview_category"))).selectByVisibleText(category);
    }
    driver.findElement(By.name("overview_url")).clear();
    driver.findElement(By.name("overview_url")).sendKeys(url);
    driver.findElement(By.name("overview_description")).clear();
    driver.findElement(By.name("overview_description")).sendKeys(description);
    driver.findElement(By.name("images_thumbnail")).sendKeys(FrameworkPathUtil.getReportLocation()
                                                             +"/../src/test/resources/images/thumbnail.jpg");
    driver.findElement(By.name("images_banner")).sendKeys(FrameworkPathUtil.getReportLocation()
                                                          +"/../src/test/resources/images/banner.jpg");
    driver.findElement(By.id("btn-create-asset")).click();
    wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("Add"+assetType)));
}
 
Example #7
Source File: ParagraphActionsIT.java    From zeppelin with Apache License 2.0 6 votes vote down vote up
@Test
public void testWidth() throws Exception {
  try {
    createNewNote();
    waitForParagraph(1, "READY");

    collector.checkThat("Default Width is 12 ",
        driver.findElement(By.xpath("//div[contains(@class,'col-md-12')]")).isDisplayed(),
        CoreMatchers.equalTo(true));
    for (Integer newWidth = 1; newWidth <= 11; newWidth++) {
      clickAndWait(By.xpath(getParagraphXPath(1) + "//span[@class='icon-settings']"));
      String visibleText = newWidth.toString();
      new Select(driver.findElement(By.xpath(getParagraphXPath(1)
          + "//ul/li/a/select[(@ng-model='paragraph.config.colWidth')]"))).selectByVisibleText(visibleText);
      collector.checkThat("New Width is : " + newWidth,
          driver.findElement(By.xpath("//div[contains(@class,'col-md-" + newWidth + "')]")).isDisplayed(),
          CoreMatchers.equalTo(true));
    }
    deleteTestNotebook(driver);
  } catch (Exception e) {
    handleException("Exception in ParagraphActionsIT while testWidth ", e);
  }
}
 
Example #8
Source File: WebDriverService.java    From cerberus-source with GNU General Public License v3.0 6 votes vote down vote up
@Override
public String getValueFromHTMLVisible(Session session, Identifier identifier) {
    String result = null;
    AnswerItem answer = this.getSeleniumElement(session, identifier, true, false);
    if (answer.isCodeEquals(MessageEventEnum.ACTION_SUCCESS_WAIT_ELEMENT.getCode())) {
        WebElement webElement = (WebElement) answer.getItem();
        if (webElement != null) {
            if (webElement.getTagName().equalsIgnoreCase("select")) {
                Select select = (Select) webElement;
                result = select.getFirstSelectedOption().getText();
            } else if (webElement.getTagName().equalsIgnoreCase("option") || webElement.getTagName().equalsIgnoreCase("input")) {
                result = webElement.getAttribute("value");
            } else {
                result = webElement.getText();
            }
        }
    }

    return result;
}
 
Example #9
Source File: FieldActionsTests.java    From vividus with Apache License 2.0 6 votes vote down vote up
@Test
void testSelectItemInDDLMultiSelectNotAdditable()
{
    WebElement selectedElement = mock(WebElement.class);
    when(selectedElement.isSelected()).thenReturn(true);
    when(selectedElement.getAttribute(INDEX)).thenReturn(Integer.toString(1));
    Select select = findDropDownListWithParameters(true);

    List<WebElement> options = List.of(webElement, selectedElement);
    when(select.getOptions()).thenReturn(options);
    when(webElementActions.getElementText(webElement)).thenReturn(TEXT);
    when(webElementActions.getElementText(selectedElement)).thenReturn("not" + TEXT);
    fieldActions.selectItemInDropDownList(select, TEXT, false);
    verify(webElementActions).getElementText(webElement);
    verify(waitActions).waitForPageLoad();
    verify(softAssert).assertTrue(ITEMS_WITH_THE_TEXT_TEXT_ARE_SELECTED_FROM_A_DROP_DOWN,
            true);
}
 
Example #10
Source File: MvcTest.java    From tomee with Apache License 2.0 6 votes vote down vote up
@When("^I submit a new user with name: (.*?) age: (\\d+) country: (.*?) state: (.*?) server: (.*?) description: (.*?)$")
public void submitNewUser(final String name, final Integer age, final String country, final String state, final String server, final String description) {
    webDriver.findElement(By.id("name")).click();
    webDriver.findElement(By.id("name")).clear();
    webDriver.findElement(By.id("name")).sendKeys(name);
    webDriver.findElement(By.id("age")).clear();
    webDriver.findElement(By.id("age")).sendKeys(age.toString());
    webDriver.findElement(By.id("state")).clear();
    webDriver.findElement(By.id("state")).sendKeys(state);
    webDriver.findElement(By.xpath("//input[@name='server'][@value='" + server + "']")).click();
    webDriver.findElement(By.id("country")).click();
    new Select(webDriver.findElement(By.id("country"))).selectByVisibleText(country);
    webDriver.findElement(By.id("description")).click();
    webDriver.findElement(By.id("description")).clear();
    webDriver.findElement(By.id("description")).sendKeys(description);
    webDriver.findElement(By.xpath("(.//*[normalize-space(text()) and normalize-space(.)='Description:'])[1]/following::button[1]")).click();
}
 
Example #11
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 #12
Source File: ParagraphActionsIT.java    From zeppelin with Apache License 2.0 6 votes vote down vote up
@Test
public void testFontSize() throws Exception {
  try {
    createNewNote();
    waitForParagraph(1, "READY");
    Float height = Float.valueOf(driver.findElement(By.xpath("//div[contains(@class,'ace_content')]"))
        .getCssValue("height").replace("px", ""));
    for (Integer newFontSize = 10; newFontSize <= 20; newFontSize++) {
      clickAndWait(By.xpath(getParagraphXPath(1) + "//span[@class='icon-settings']"));
      String visibleText = newFontSize.toString();
      new Select(driver.findElement(By.xpath(getParagraphXPath(1)
          + "//ul/li/a/select[(@ng-model='paragraph.config.fontSize')]"))).selectByVisibleText(visibleText);
      Float newHeight = Float.valueOf(driver.findElement(By.xpath("//div[contains(@class,'ace_content')]"))
          .getCssValue("height").replace("px", ""));
      collector.checkThat("New Font size is : " + newFontSize,
          newHeight > height,
          CoreMatchers.equalTo(true));
      height = newHeight;
    }
    deleteTestNotebook(driver);
  } catch (Exception e) {
    handleException("Exception in ParagraphActionsIT while testFontSize ", e);
  }
}
 
Example #13
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 #14
Source File: ESStoreSearchGadgetListTestCase.java    From product-es with Apache License 2.0 6 votes vote down vote up
@Test(groups = "wso2.es.store", description = "Search by newly added asset Version",
        dependsOnMethods = "testAddAsset")
public void testESStoreSearchNewlyAddedAssetsVersion() throws Exception {
    driver.get(baseUrl + "/store/pages/top-assets");
    driver.findElement(By.cssSelector("i.icon-cog")).click();
    driver.findElement(By.cssSelector("i.icon-sort-down")).click();
    driver.findElement(By.id("search")).click();
    driver.findElement(By.name("overview_version")).clear();
    driver.findElement(By.name("overview_version")).sendKeys(assetVersion);
    new Select(driver.findElement(By.id("overview_category"))).selectByVisibleText(assetCategory);
    driver.findElement(By.id("search-button2")).click();
    driver.findElementPoll(By.linkText(assetName), 10);
    wait.until(ExpectedConditions.textToBePresentInElementLocated(By.xpath("//h4[contains(.,'"+assetName+"')]"), assetName));
    assertEquals(assetName, driver.findElement(By.cssSelector("h4")).getText(),
            "Newly added gadget is not found in the result of search by version : " +
                    assetVersion);
    wait.until(ExpectedConditions.presenceOfElementLocated(By.cssSelector("img")));
    driver.findElement(By.cssSelector("img")).click();
    wait.until(ExpectedConditions.textToBePresentInElementLocated(By.linkText("Description"),
            "Description"));
    assertEquals("Version 1.2.3", driver.findElement(By.cssSelector("small")).getText(),
            "Newly added gadget's version is incorrect in the store");
}
 
Example #15
Source File: PortalMarketServiceWT.java    From development with Apache License 2.0 6 votes vote down vote up
@Test
public void test03definePublishOption() throws Exception {

    tester.visitPortal(PortalPathSegments.DEFINE_PUBLISHOPTION);
    tester.waitForElement(By.id(
            PortalHtmlElements.DEFINE_PUBLISH_OPTION_DROPDOWN_SERVICENAME),
            10);
    Select dropdownServiceName = new Select(tester.getDriver().findElement(
            By.id(PortalHtmlElements.DEFINE_PUBLISH_OPTION_DROPDOWN_SERVICENAME)));
    dropdownServiceName
            .selectByVisibleText(PlaygroundSuiteTest.marketServiceName);

    Select dropdownMarketplace = new Select(tester.getDriver().findElement(
            By.id(PortalHtmlElements.DEFINE_PUBLISH_OPTION_DROPDOWN_MARKETPLACE)));
    dropdownMarketplace.selectByValue(PlaygroundSuiteTest.supplierOrgId);

    tester.waitForElementVisible(
            By.id(PortalHtmlElements.DEFINE_PUBLISH_OPTION_BUTTON_SAVE),
            10);
    tester.clickElement(
            PortalHtmlElements.DEFINE_PUBLISH_OPTION_BUTTON_SAVE);

    assertTrue(tester.getExecutionResult());

}
 
Example #16
Source File: SeleniumSelect.java    From phoenix.webui.framework with Apache License 2.0 5 votes vote down vote up
@Override
public boolean deselectByText(Element element, String text)
{
	Select select = createSelect(element);
	if(select != null)
	{
		select.deselectByVisibleText(text);
		return true;
	}

	return false;
}
 
Example #17
Source File: EncapsulateOperation.java    From LuckyFrameClient with GNU Affero General Public License v3.0 5 votes vote down vote up
public static String selectOperation(WebElement we, String operation, String operationValue) {
    String result = "";
    // �����������
    Select select = new Select(we);

    // �����������¼�
    switch (operation) {
        case "selectbyvisibletext":
            select.selectByVisibleText(operationValue);
            result = "���������ͨ��VisibleText����ѡ��...��VisibleText����ֵ:" + operationValue + "��";
            LogUtil.APP.info("���������ͨ��VisibleText����ѡ��...��VisibleText����ֵ:{}��",operationValue);
            break;
        case "selectbyvalue":
            select.selectByValue(operationValue);
            result = "���������ͨ��Value����ѡ��...��Value����ֵ:" + operationValue + "��";
            LogUtil.APP.info("���������ͨ��Value����ѡ��...��Value����ֵ:{}��",operationValue);
            break;
        case "selectbyindex":
            select.selectByIndex(Integer.parseInt(operationValue));
            result = "���������ͨ��Index����ѡ��...��Index����ֵ:" + operationValue + "��";
            LogUtil.APP.info("���������ͨ��Index����ѡ��...��Index����ֵ:{}��",operationValue);
            break;
        case "isselect":
            result = "��ȡ����ֵ�ǡ�" + we.isSelected() + "��";
            LogUtil.APP.info("�ж϶����Ƿ��Ѿ���ѡ��...�����ֵ:{}��",we.isSelected());
            break;
        default:
            break;
    }
    return result;
}
 
Example #18
Source File: SeleniumSelect.java    From phoenix.webui.framework with Apache License 2.0 5 votes vote down vote up
@Override
public boolean isMultiple(Element element)
{
	Select select = createSelect(element);
	if(select != null)
	{
		return select.isMultiple();
	}

	return false;
}
 
Example #19
Source File: ClientScopesSetupForm.java    From keycloak with Apache License 2.0 5 votes vote down vote up
static Set<String> getSelectValues(Select select) {
    Set<String> roles = new HashSet<>();
    for (WebElement option : select.getOptions()) {
        roles.add(getTextFromElement(option).trim());
    }
    return roles;
}
 
Example #20
Source File: NameIdAddPage.java    From oxTrust with MIT License 5 votes vote down vote up
public void assertNamedDontExist(String name) {
	try {
		Select select = new Select(webDriver.findElement(By.className("sourceAttributeSelectBox")));
		Assert.assertFalse(select.getFirstSelectedOption().getText().equalsIgnoreCase(name));
	} catch (Exception e) {
		Assert.assertTrue(true);
	}

}
 
Example #21
Source File: AbstractElementAction.java    From coteafs-selenium with Apache License 2.0 5 votes vote down vote up
@Override
public void selectByValue(final String value) {
    perform(e -> {
        final Select select = new Select(e);
        select.selectByValue(value);
    });
}
 
Example #22
Source File: AbstractElementAction.java    From coteafs-selenium with Apache License 2.0 5 votes vote down vote up
@Override
public <T extends IMouseActions> List<T> selectedOptions() {
    return get(e -> {
        final Select select = new Select(e);
        return select.getAllSelectedOptions()
            .stream()
            .map(o -> (T) new AbstractElementAction<>(this.browserAction, o, o.getText()))
            .collect(Collectors.toList());
    });
}
 
Example #23
Source File: DetailsTabUiTest.java    From warnings-ng-plugin with MIT License 5 votes vote down vote up
/**
 * When selecting different options in the dropdown menu that controls the numbers of displayed rows.
 */
@Test
public void shouldShowTheCorrectNumberOfRowsSelectedByLength() {
    FreeStyleJob job = createFreeStyleJob("findbugs-severities.xml");
    job.addPublisher(IssuesRecorder.class, recorder -> recorder.setToolWithPattern("FindBugs", "**/*.xml"));
    job.save();

    Build build = job.startBuild().waitUntilFinished();
    build.open();

    AnalysisSummary resultPage = new AnalysisSummary(build, "findbugs");
    assertThat(resultPage).isDisplayed();

    AnalysisResult findBugsAnalysisResult = resultPage.openOverallResult();

    assertThat(findBugsAnalysisResult).hasAvailableTabs(Tab.ISSUES);

    findBugsAnalysisResult.openPropertiesTable(Tab.ISSUES);

    Select issuesLengthSelect = findBugsAnalysisResult.getLengthSelectElementByActiveTab();
    issuesLengthSelect.selectByValue("10");

    WebElement issuesInfo = findBugsAnalysisResult.getInfoElementByActiveTab();
    waitUntilCondition(issuesInfo, "Showing 1 to 10 of 12 entries");

    WebElement issuesPaginate = findBugsAnalysisResult.getPaginateElementByActiveTab();
    List<WebElement> issuesPaginateButtons = issuesPaginate.findElements(By.cssSelector("ul li"));

    assertThat(issuesPaginateButtons.size()).isEqualTo(2);
    assertThat(ExpectedConditions.elementToBeClickable(issuesPaginateButtons.get(1)));

    issuesLengthSelect.selectByValue("25");
    waitUntilCondition(issuesInfo, "Showing 1 to 12 of 12 entries");

    issuesPaginateButtons.clear();
    issuesPaginateButtons = issuesPaginate.findElements(By.cssSelector("ul li"));

    assertThat(issuesPaginateButtons.size()).isEqualTo(1);
}
 
Example #24
Source File: SeleniumSelect.java    From phoenix.webui.framework with Apache License 2.0 5 votes vote down vote up
@Override
public boolean selectByIndex(Element element, int index)
{
	Select select = createSelect(element);
	if(select != null)
	{
		select.selectByIndex(index);
		return true;
	}

	return false;
}
 
Example #25
Source File: TrAddPage.java    From oxTrust with MIT License 5 votes vote down vote up
public void setMetadataType(String mtype) {
	if (mtype.equalsIgnoreCase("federation")) {
		fluentWait(LARGE);
	}
	fluentWait(ONE_SEC);
	WebElement element = webDriver.findElement(By.className("MetaDataType"));
	Select select = new Select(element);
	select.selectByVisibleText(mtype);
}
 
Example #26
Source File: InstructorFeedbackResultsPage.java    From teammates with GNU General Public License v2.0 5 votes vote down vote up
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();
}
 
Example #27
Source File: Dropdown.java    From Cognizant-Intelligent-Test-Scripter with Apache License 2.0 5 votes vote down vote up
private void selectSingle(SelectType selectType, SelectBy selectBy) {
    switch (selectType) {
        case Select:
            select(selectBy);
            break;
        case DeSelect:
            deSelect(selectBy);
            break;
    }

}
 
Example #28
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 #29
Source File: Dropdown.java    From Cognizant-Intelligent-Test-Scripter with Apache License 2.0 5 votes vote down vote up
private void deSelect(Select select, String Data, SelectBy selectBy) {
    switch (selectBy) {
        case Index:
            select.deselectByIndex(Integer.parseInt(Data));
            break;
        case Text:
            select.deselectByVisibleText(Data);
            break;
        case Value:
            select.deselectByValue(Data);
            break;
    }

}
 
Example #30
Source File: SeleniumSelect.java    From phoenix.webui.framework with Apache License 2.0 5 votes vote down vote up
/**
 * 转化为Selenium支持的下拉列表对象
 * @param element
 * @return
 */
private Select createSelect(Element element)
{
	WebElement webEle = searchStrategyUtils.findStrategy(WebElement.class, element).search(element);
	if (webEle != null)
	{
		return new Select(webEle);
	}

	return null;
}