Package org.openqa.selenium.support.ui
Class Select
- java.lang.Object
-
- org.openqa.selenium.support.ui.Select
-
-
Constructor Summary
Constructors Constructor Description Select(org.openqa.selenium.WebElement element)
Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
deselectAll()
Clear all selected entries.void
deselectByIndex(int index)
Deselect the option at the given index.void
deselectByValue(java.lang.String value)
Deselect all options that have a value matching the argument.void
deselectByVisibleText(java.lang.String text)
Deselect all options that display text matching the argument.boolean
equals(java.lang.Object o)
java.util.List<org.openqa.selenium.WebElement>
getAllSelectedOptions()
org.openqa.selenium.WebElement
getFirstSelectedOption()
java.util.List<org.openqa.selenium.WebElement>
getOptions()
org.openqa.selenium.WebElement
getWrappedElement()
int
hashCode()
boolean
isMultiple()
void
selectByIndex(int index)
Select the option at the given index.void
selectByValue(java.lang.String value)
Select all options that have a value matching the argument.void
selectByVisibleText(java.lang.String text)
Select all options that display text matching the argument.
-
-
-
Constructor Detail
-
Select
public Select(org.openqa.selenium.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 org.openqa.selenium.WebElement getWrappedElement()
- Specified by:
getWrappedElement
in interfaceorg.openqa.selenium.WrapsElement
-
isMultiple
public boolean isMultiple()
- Specified by:
isMultiple
in interfaceISelect
- 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<org.openqa.selenium.WebElement> getOptions()
- Specified by:
getOptions
in interfaceISelect
- Returns:
- All options belonging to this select tag
-
getAllSelectedOptions
public java.util.List<org.openqa.selenium.WebElement> getAllSelectedOptions()
- Specified by:
getAllSelectedOptions
in interfaceISelect
- Returns:
- All selected options belonging to this select tag
-
getFirstSelectedOption
public org.openqa.selenium.WebElement getFirstSelectedOption()
- Specified by:
getFirstSelectedOption
in interfaceISelect
- Returns:
- The first selected option in this select tag (or the currently selected option in a normal select)
- Throws:
org.openqa.selenium.NoSuchElementException
- If no option is selected
-
selectByVisibleText
public void selectByVisibleText(java.lang.String text)
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 interfaceISelect
- Parameters:
text
- The visible text to match against- Throws:
org.openqa.selenium.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 interfaceISelect
- Parameters:
index
- The option at this index will be selected- Throws:
org.openqa.selenium.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 interfaceISelect
- Parameters:
value
- The value to match against- Throws:
org.openqa.selenium.NoSuchElementException
- If no matching option elements are found
-
deselectAll
public void deselectAll()
Clear all selected entries. This is only valid when the SELECT supports multiple selections.- Specified by:
deselectAll
in interfaceISelect
- 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 interfaceISelect
- Parameters:
value
- The value to match against- Throws:
org.openqa.selenium.NoSuchElementException
- If no matching option elements are foundjava.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 interfaceISelect
- Parameters:
index
- The option at this index will be deselected- Throws:
org.openqa.selenium.NoSuchElementException
- If no matching option elements are foundjava.lang.UnsupportedOperationException
- If the SELECT does not support multiple selections
-
deselectByVisibleText
public void deselectByVisibleText(java.lang.String text)
Deselect all options that display text matching the argument. That is, when given "Bar" this would deselect an option like:<option value="foo">Bar</option>
- Specified by:
deselectByVisibleText
in interfaceISelect
- Parameters:
text
- The visible text to match against- Throws:
org.openqa.selenium.NoSuchElementException
- If no matching option elements are foundjava.lang.UnsupportedOperationException
- If the SELECT does not support multiple selections
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
-