Java Code Examples for org.openqa.selenium.support.ui.Select#getFirstSelectedOption()
The following examples show how to use
org.openqa.selenium.support.ui.Select#getFirstSelectedOption() .
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: Text.java From Cognizant-Intelligent-Test-Scripter with Apache License 2.0 | 5 votes |
private void checkElementTypeBeforeProcessing() { if (Element != null) { if (Element.getTagName().equalsIgnoreCase("select")) { Select select = new Select(Element); Element = select.getFirstSelectedOption(); System.out.println("As it is Select Element assserting " + "the text of first selected Element"); } } }
Example 2
Source File: ToolBarController.java From mycore with GNU General Public License v3.0 | 5 votes |
/** * checks if the image with the <b>orderLabel</b> is selected * * @param oderLabel * @return true if the if the image with the <b>orderLabel</b> is selected */ public boolean isImageSelected(String oderLabel) { By selector = By.cssSelector(SELECTBOX_SELECTOR); WebElement element = this.getDriver().findElement(selector); Select select = new Select(element); return select != null && select.getFirstSelectedOption() != null && select.getFirstSelectedOption().getText().equalsIgnoreCase(oderLabel); }
Example 3
Source File: AppPage.java From teammates with GNU General Public License v2.0 | 3 votes |
/** * Selects the option by visible text and returns whether the dropdown value has changed. * * @throws AssertionError if the selected option is not the one we wanted to select * * @see Select#selectByVisibleText(String) */ boolean selectDropdownByVisibleValue(WebElement element, String text) { Select select = new Select(element); WebElement originalSelectedOption = select.getFirstSelectedOption(); select.selectByVisibleText(text); WebElement newSelectedOption = select.getFirstSelectedOption(); assertEquals(text, newSelectedOption.getText().trim()); return !newSelectedOption.equals(originalSelectedOption); }
Example 4
Source File: AppPage.java From teammates with GNU General Public License v2.0 | 3 votes |
/** * Selects the option by value and returns whether the dropdown value has changed. * * @throws AssertionError if the selected option is not the one we wanted to select * * @see Select#selectByValue(String) */ boolean selectDropdownByActualValue(WebElement element, String value) { Select select = new Select(element); WebElement originalSelectedOption = select.getFirstSelectedOption(); select.selectByValue(value); WebElement newSelectedOption = select.getFirstSelectedOption(); assertEquals(value, newSelectedOption.getAttribute("value")); return !newSelectedOption.equals(originalSelectedOption); }