Java Code Examples for com.gargoylesoftware.htmlunit.html.HtmlSelect#getSelectedOptions()

The following examples show how to use com.gargoylesoftware.htmlunit.html.HtmlSelect#getSelectedOptions() . 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: HTMLSelectElement.java    From htmlunit with Apache License 2.0 5 votes vote down vote up
/**
 * Returns the actual value of the selected Option.
 * @return the value
 */
@Override
@JsxGetter
public String getValue() {
    final HtmlSelect htmlSelect = getHtmlSelect();
    final List<HtmlOption> selectedOptions = htmlSelect.getSelectedOptions();
    if (selectedOptions.isEmpty()) {
        return "";
    }
    return ((HTMLOptionElement) selectedOptions.get(0).getScriptableObject()).getValue();
}
 
Example 2
Source File: HTMLSelectElement.java    From HtmlUnit-Android with Apache License 2.0 5 votes vote down vote up
/**
 * Returns the actual value of the selected Option.
 * @return the value
 */
@Override
public String getValue() {
    final HtmlSelect htmlSelect = getHtmlSelect();
    final List<HtmlOption> selectedOptions = htmlSelect.getSelectedOptions();
    if (selectedOptions.isEmpty()) {
        return "";
    }
    return ((HTMLOptionElement) selectedOptions.get(0).getScriptableObject()).getValue();
}