org.openqa.selenium.support.ui.Select#selectByValue ( )源码实例Demo

下面列出了org.openqa.selenium.support.ui.Select#selectByValue ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: archiva   文件: AbstractSeleniumTest.java
public WebElement selectValue( String locator, String value, boolean scrollToView )
{
    int count = 5;
    boolean check = true;
    WebDriverWait wait = new WebDriverWait( getWebDriver( ), 10 );
    WebElement element = null;
    while(check && count-->0)
    {
        try
        {
            element = findElement( locator );
            List<WebElement> elementList = new ArrayList<>( );
            elementList.add( element );
            wait.until( ExpectedConditions.visibilityOfAllElements( elementList ) );
            check=false;
        } catch (Throwable e) {
            logger.info("Waiting for select element {} to be visible", locator);
        }
    }
    Select select = new Select(element);
    select.selectByValue( value );
    return element;
}
 
源代码2 项目: development   文件: PortalMarketServiceWT.java
@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());

}
 
源代码3 项目: LuckyFrameClient   文件: EncapsulateOperation.java
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;
}
 
源代码4 项目: warnings-ng-plugin   文件: DetailsTabUiTest.java
/**
 * 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);
}
 
源代码5 项目: senbot   文件: FormService.java
public void setSelectOptionOnView(String viewName, String elementName, String optionText) throws IllegalArgumentException, IllegalAccessException {
	String checkValue = getReferenceService().namespaceString(optionText);
	
	WebElement elementFromReferencedView = seleniumElementService.getElementFromReferencedView(viewName, elementName);
	Select select = new Select(elementFromReferencedView);
	try{			
		select.selectByVisibleText(checkValue);
	}
	catch(NoSuchElementException nse) {
		//could mean the value to use is an actual value
		select.selectByValue(checkValue);
	}
}
 
源代码6 项目: phoenix.webui.framework   文件: SeleniumSelect.java
@Override
public boolean selectByValue(Element element, String value)
{
	Select select = createSelect(element);
	if(select != null)
	{
		select.selectByValue(value);
		return true;
	}

	return false;
}
 
源代码7 项目: bromium   文件: RecordSelectValueIT.java
@Override
public void run(RecordingSimulatorModule recordingSimulatorModule) throws InterruptedException {
    String baseUrl = (String) opts.get(URL);
    WebDriver driver = recordingSimulatorModule.getWebDriver();
    driver.get(baseUrl + TestUtils.Pages.SELECT_VALUE_DEMO_PAGE);

    Select select = new Select(driver.findElement(By.id("select-element")));
    select.selectByValue("first");
    Thread.sleep(1000);

}
 
源代码8 项目: opentest   文件: SelectListOption.java
@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.");
    }

}
 
源代码9 项目: teammates   文件: StudentProfilePage.java
/**
 * Selects student nationality from the dropdown list if the nationality is
 * valid, otherwise it fails with a message.
 */
public void selectNationality(String studentNationality) {
    if (NationalityHelper.getNationalities().contains(studentNationality) || "".equals(studentNationality)) {
        Select dropdown = new Select(studentNationalityDropdown);
        dropdown.selectByValue(studentNationality);
    } else {
        fail("Given nationality " + studentNationality + " is not valid!");
    }
}
 
源代码10 项目: keycloak   文件: TokenSettings.java
private void setTimeout(Select timeoutElement, WebElement unitElement,
        int timeout, TimeUnit unit) {
    timeoutElement.selectByValue(capitalize(unit.name().toLowerCase()));
    UIUtils.setTextInputValue(unitElement, valueOf(timeout));
}
 
源代码11 项目: attic-rave   文件: PageOperationsSteps.java
@When("I choose the two column layout")
public void selectTwoColumnLayout() {
    final Select layouts = new Select(portal.findElement(By.id("pageLayout")));
    layouts.selectByValue("columns_2");
}
 
源代码12 项目: SeleniumCucumber   文件: DropDownHelper.java
public void SelectUsingValue(By locator,String value) {
	Select select = new Select(getElement(locator));
	select.selectByValue(value);
	oLog.info("Locator : " + locator + " Value : " + value);
}
 
源代码13 项目: find   文件: TableView.java
public void showEntries(final EntryCount entryCount) {
    final Select select = new Select(findElement(By.cssSelector(".dataTables_length select")));

    select.selectByValue(entryCount.value);
}
 
源代码14 项目: oxTrust   文件: AttributesPage.java
public void editType() {
	Select typeEdited = new Select(webDriver.findElement(By.className("editTypeField")));
	typeEdited.deselectAll();
	typeEdited.selectByValue("ADMIN");

}
 
源代码15 项目: oxTrust   文件: AttributesPage.java
public void viewType() {
	Select typeViewed = new Select(webDriver.findElement(By.className("viewTypeField")));
	typeViewed.deselectAll();
	typeViewed.selectByValue("ADMIN");
}
 
源代码16 项目: oxTrust   文件: AttributesPage.java
public void usageType() {
	Select typeUsed = new Select(webDriver.findElement(By.className("usageTypeField")));
	typeUsed.deselectAll();
	typeUsed.selectByValue("OPENID");
}
 
源代码17 项目: attic-rave   文件: ProfileSteps.java
@When("I choose the status as \"$status\"")
public void changeStatus(String status) {
    final Select relationshipStatus = new Select(portal.findElement(By.id("statusField")));
    relationshipStatus.selectByValue(status);
}
 
源代码18 项目: teammates   文件: InstructorCourseEditPage.java
private void selectNewTimeZone(String timeZone) {
    Select dropdown = new Select(timeZoneDropDown);
    dropdown.selectByValue(timeZone);
}
 
源代码19 项目: teammates   文件: InstructorCoursesPage.java
private void selectNewTimeZone(String timeZone) {
    Select dropdown = new Select(timeZoneDropdown);
    dropdown.selectByValue(timeZone);
}
 
源代码20 项目: development   文件: WebTester.java
/**
 * 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);
}