Java Code Examples for org.openqa.selenium.support.ui.Select#selectByValue()
The following examples show how to use
org.openqa.selenium.support.ui.Select#selectByValue() .
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: AbstractSeleniumTest.java From archiva with Apache License 2.0 | 6 votes |
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; }
Example 2
Source File: PortalMarketServiceWT.java From development with Apache License 2.0 | 6 votes |
@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 3
Source File: EncapsulateOperation.java From LuckyFrameClient with GNU Affero General Public License v3.0 | 5 votes |
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 4
Source File: DetailsTabUiTest.java From warnings-ng-plugin with MIT License | 5 votes |
/** * 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 5
Source File: FormService.java From senbot with MIT License | 5 votes |
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); } }
Example 6
Source File: SeleniumSelect.java From phoenix.webui.framework with Apache License 2.0 | 5 votes |
@Override public boolean selectByValue(Element element, String value) { Select select = createSelect(element); if(select != null) { select.selectByValue(value); return true; } return false; }
Example 7
Source File: RecordSelectValueIT.java From bromium with MIT License | 5 votes |
@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); }
Example 8
Source File: SelectListOption.java From opentest with MIT License | 5 votes |
@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 9
Source File: StudentProfilePage.java From teammates with GNU General Public License v2.0 | 5 votes |
/** * 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!"); } }
Example 10
Source File: InstructorCoursesPage.java From teammates with GNU General Public License v2.0 | 4 votes |
private void selectNewTimeZone(String timeZone) { Select dropdown = new Select(timeZoneDropdown); dropdown.selectByValue(timeZone); }
Example 11
Source File: InstructorCourseEditPage.java From teammates with GNU General Public License v2.0 | 4 votes |
private void selectNewTimeZone(String timeZone) { Select dropdown = new Select(timeZoneDropDown); dropdown.selectByValue(timeZone); }
Example 12
Source File: ProfileSteps.java From attic-rave with Apache License 2.0 | 4 votes |
@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); }
Example 13
Source File: AttributesPage.java From oxTrust with MIT License | 4 votes |
public void usageType() { Select typeUsed = new Select(webDriver.findElement(By.className("usageTypeField"))); typeUsed.deselectAll(); typeUsed.selectByValue("OPENID"); }
Example 14
Source File: AttributesPage.java From oxTrust with MIT License | 4 votes |
public void viewType() { Select typeViewed = new Select(webDriver.findElement(By.className("viewTypeField"))); typeViewed.deselectAll(); typeViewed.selectByValue("ADMIN"); }
Example 15
Source File: AttributesPage.java From oxTrust with MIT License | 4 votes |
public void editType() { Select typeEdited = new Select(webDriver.findElement(By.className("editTypeField"))); typeEdited.deselectAll(); typeEdited.selectByValue("ADMIN"); }
Example 16
Source File: TableView.java From find with MIT License | 4 votes |
public void showEntries(final EntryCount entryCount) { final Select select = new Select(findElement(By.cssSelector(".dataTables_length select"))); select.selectByValue(entryCount.value); }
Example 17
Source File: DropDownHelper.java From SeleniumCucumber with GNU General Public License v3.0 | 4 votes |
public void SelectUsingValue(By locator,String value) { Select select = new Select(getElement(locator)); select.selectByValue(value); oLog.info("Locator : " + locator + " Value : " + value); }
Example 18
Source File: PageOperationsSteps.java From attic-rave with Apache License 2.0 | 4 votes |
@When("I choose the two column layout") public void selectTwoColumnLayout() { final Select layouts = new Select(portal.findElement(By.id("pageLayout"))); layouts.selectByValue("columns_2"); }
Example 19
Source File: TokenSettings.java From keycloak with Apache License 2.0 | 4 votes |
private void setTimeout(Select timeoutElement, WebElement unitElement, int timeout, TimeUnit unit) { timeoutElement.selectByValue(capitalize(unit.name().toLowerCase())); UIUtils.setTextInputValue(unitElement, valueOf(timeout)); }
Example 20
Source File: WebTester.java From development with Apache License 2.0 | 2 votes |
/** * 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); }