Download as pdf or txt
Download as pdf or txt
You are on page 1of 6

10/11/21, 3:12 PM Select

OVERVIEW PACKAGE CLASS USE TREE DEPRECATED INDEX HELP

FRAMES NO FRAMES ALL CLASSES SEARCH:



Search

SUMMARY: NESTED | FIELD | CONSTR | METHOD DETAIL: FIELD | CONSTR | METHOD
 
Package org.openqa.selenium.support.ui

Class Select

java.lang.Object
org.openqa.selenium.support.ui.Select

All Implemented Interfaces:


ISelect, WrapsElement

public class Select

extends java.lang.Object

implements ISelect, WrapsElement

Models a SELECT tag, providing helper methods to select and deselect options.

Constructor Summary

Constructors

Constructor Description

Select​
(WebElement element) Constructor.

Method Summary

All Methods Instance Methods Concrete Methods

Modifier and Type Method Description

void deselectAll() Clear all selected entries.

void deselectByIndex​ Deselect the option at the given


(int index) index.

void deselectByValue​ Deselect all options that have a


(java.lang.String value) value matching the argument.

void deselectByVisibleText​ Deselect all options that display


(java.lang.String text) text matching the argument.

boolean equals​  
(java.lang.Object o)

java.util.List<WebElement> getAllSelectedOptions()  

WebElement getFirstSelectedOption()  

https://www.selenium.dev/selenium/docs/api/java/org/openqa/selenium/support/ui/Select.html 1/6
10/11/21, 3:12 PM Select

java.util.List<WebElement> getOptions()  

OVERVIEW PACKAGE CLASS USE TREE DEPRECATED INDEX HELP


WebElement getWrappedElement()  
FRAMES NO FRAMES ALL CLASSES SEARCH:

Search

int hashCode()  

SUMMARY: NESTED | FIELD | CONSTR | METHOD DETAIL: FIELD | CONSTR | METHOD
boolean isMultiple()  

void selectByIndex​
(int index) Select the option at the given
index.

void selectByValue​ Select all options that have a


(java.lang.String value) value matching the argument.

void selectByVisibleText​ Select all options that display text


(java.lang.String text) matching the argument.

Methods inherited from class java.lang.Object

clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait

Constructor Detail

Select

public Select​
(WebElement element)

Constructor. A check is made that the given element is, indeed, a SELECT tag. If it is not,
then an
UnexpectedTagNameException is thrown.

Parameters:
element - SELECT element to wrap
Throws:
UnexpectedTagNameException - when element is not a SELECT

Method Detail

getWrappedElement

public WebElement getWrappedElement()

Specified by:
getWrappedElement in interface WrapsElement

https://www.selenium.dev/selenium/docs/api/java/org/openqa/selenium/support/ui/Select.html 2/6
10/11/21, 3:12 PM Select

OVERVIEW PACKAGE CLASS USE TREE DEPRECATED INDEX HELP

isMultiple
FRAMES NO FRAMES ALL CLASSES SEARCH:

Search

SUMMARY: NESTED | FIELD | CONSTR | METHOD
public boolean isMultiple() DETAIL: FIELD | CONSTR | METHOD

Specified by:
isMultiple in interface ISelect
Returns:
Whether this select element support selecting multiple options at the same time? This
is done by
checking the value of the "multiple" attribute.

getOptions

public java.util.List<WebElement> getOptions()

Specified by:
getOptions in interface ISelect
Returns:
All options belonging to this select tag

getAllSelectedOptions

public java.util.List<WebElement> getAllSelectedOptions()

Specified by:
getAllSelectedOptions in interface ISelect
Returns:
All selected options belonging to this select tag

getFirstSelectedOption

public WebElement getFirstSelectedOption()

Specified by:
getFirstSelectedOption in interface ISelect
Returns:
The first selected option in this select tag (or the currently selected option in a
normal select)
Throws:
NoSuchElementException - If no option is selected

https://www.selenium.dev/selenium/docs/api/java/org/openqa/selenium/support/ui/Select.html 3/6
10/11/21, 3:12 PM Select

selectByVisibleText
OVERVIEW PACKAGE CLASS USE TREE DEPRECATED INDEX HELP

public void selectByVisibleText​
FRAMES NO FRAMES ALL CLASSES (java.lang.String text) SEARCH:

Search

SUMMARY: NESTED | FIELD | CONSTR | METHOD DETAIL: FIELD | CONSTR | METHOD
Select all options that display text matching the argument. That is, when given "Bar" this
would select
an option like:
<option value="foo">Bar</option>

Specified by:
selectByVisibleText in interface ISelect
Parameters:
text - The visible text to match against
Throws:
NoSuchElementException - If no matching option elements are found

selectByIndex

public void selectByIndex​
(int index)

Select the option at the given index. This is done by examining the "index" attribute of an
element,
and not merely by counting.

Specified by:
selectByIndex in interface ISelect
Parameters:
index - The option at this index will be selected
Throws:
NoSuchElementException - If no matching option elements are found

selectByValue

public void selectByValue​
(java.lang.String value)

Select all options that have a value matching the argument. That is, when given "foo" this
would
select an option like:
<option value="foo">Bar</option>

Specified by:
selectByValue in interface ISelect
Parameters:
value - The value to match against
Throws:
NoSuchElementException - If no matching option elements are found

deselectAll

https://www.selenium.dev/selenium/docs/api/java/org/openqa/selenium/support/ui/Select.html 4/6
10/11/21, 3:12 PM Select

public void deselectAll()

OVERVIEW PACKAGE CLASS USE TREE DEPRECATED INDEX HELP


Clear all selected entries. This is only valid when the SELECT supports multiple selections.
FRAMES NO FRAMES ALL CLASSES SEARCH:

Search

Specified by:

SUMMARY: NESTED | FIELD | CONSTR | METHOD DETAIL: FIELD | CONSTR | METHOD
deselectAll in interface ISelect
Throws:
java.lang.UnsupportedOperationException - If the SELECT does not support multiple selections

deselectByValue

public void deselectByValue​
(java.lang.String value)

Deselect all options that have a value matching the argument. That is, when given "foo" this
would
deselect an option like:
<option value="foo">Bar</option>

Specified by:
deselectByValue in interface ISelect
Parameters:
value - The value to match against
Throws:
NoSuchElementException - If no matching option elements are found

java.lang.UnsupportedOperationException - If the SELECT does not support multiple selections

deselectByIndex

public void deselectByIndex​
(int index)

Deselect the option at the given index. This is done by examining the "index" attribute of an
element,
and not merely by counting.

Specified by:
deselectByIndex in interface ISelect
Parameters:
index - The option at this index will be deselected
Throws:
NoSuchElementException - If no matching option elements are found

java.lang.UnsupportedOperationException - If the SELECT does not support multiple selections

deselectByVisibleText

public void deselectByVisibleText​
(java.lang.String text)

https://www.selenium.dev/selenium/docs/api/java/org/openqa/selenium/support/ui/Select.html 5/6
10/11/21, 3:12 PM Select

Deselect all options that display text matching the argument. That is, when
given "Bar" this
would
OVERVIEW PACKAGE CLASS USE TREE DEPRECATED INDEX HELP
deselect an option like:
<option value="foo">Bar</option>
FRAMES NO FRAMES
Specified by: ALL CLASSES SEARCH:

Search

deselectByVisibleText in interface ISelect
SUMMARY: NESTED | FIELD | CONSTR | METHOD DETAIL: FIELD | CONSTR | METHOD

Parameters:
text - The visible text to match against
Throws:
NoSuchElementException - If no matching option elements are found

java.lang.UnsupportedOperationException - If the SELECT does not support multiple selections

equals

public boolean equals​
(java.lang.Object o)

Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()

Overrides:
hashCode in class java.lang.Object

OVERVIEW PACKAGE CLASS USE TREE DEPRECATED INDEX HELP

FRAMES NO FRAMES ALL CLASSES

SUMMARY: NESTED | FIELD | CONSTR | METHOD DETAIL: FIELD | CONSTR | METHOD

https://www.selenium.dev/selenium/docs/api/java/org/openqa/selenium/support/ui/Select.html 6/6

You might also like