28
28
/**
29
29
* Models a SELECT tag, providing helper methods to select and deselect options.
30
30
*/
31
- public class Select implements ISelect {
31
+ public class Select implements ISelect {
32
32
33
33
private final WebElement element ;
34
34
private final boolean isMulti ;
@@ -59,20 +59,23 @@ public Select(WebElement element) {
59
59
* @return Whether this select element support selecting multiple options at the same time? This
60
60
* is done by checking the value of the "multiple" attribute.
61
61
*/
62
+ @ Override
62
63
public boolean isMultiple () {
63
64
return isMulti ;
64
65
}
65
66
66
67
/**
67
68
* @return All options belonging to this select tag
68
69
*/
70
+ @ Override
69
71
public List <WebElement > getOptions () {
70
72
return element .findElements (By .tagName ("option" ));
71
73
}
72
74
73
75
/**
74
76
* @return All selected options belonging to this select tag
75
77
*/
78
+ @ Override
76
79
public List <WebElement > getAllSelectedOptions () {
77
80
List <WebElement > toReturn = new ArrayList <>();
78
81
@@ -90,6 +93,7 @@ public List<WebElement> getAllSelectedOptions() {
90
93
* normal select)
91
94
* @throws NoSuchElementException If no option is selected
92
95
*/
96
+ @ Override
93
97
public WebElement getFirstSelectedOption () {
94
98
for (WebElement option : getOptions ()) {
95
99
if (option .isSelected ()) {
@@ -171,6 +175,7 @@ private String getLongestSubstringWithoutSpace(String s) {
171
175
* @param index The option at this index will be selected
172
176
* @throws NoSuchElementException If no matching option elements are found
173
177
*/
178
+ @ Override
174
179
public void selectByIndex (int index ) {
175
180
String match = String .valueOf (index );
176
181
@@ -192,6 +197,7 @@ public void selectByIndex(int index) {
192
197
* @param value The value to match against
193
198
* @throws NoSuchElementException If no matching option elements are found
194
199
*/
200
+ @ Override
195
201
public void selectByValue (String value ) {
196
202
List <WebElement > options = element .findElements (By .xpath (
197
203
".//option[@value = " + Quotes .escape (value ) + "]" ));
@@ -215,6 +221,7 @@ public void selectByValue(String value) {
215
221
*
216
222
* @throws UnsupportedOperationException If the SELECT does not support multiple selections
217
223
*/
224
+ @ Override
218
225
public void deselectAll () {
219
226
if (!isMultiple ()) {
220
227
throw new UnsupportedOperationException (
@@ -236,6 +243,7 @@ public void deselectAll() {
236
243
* @throws NoSuchElementException If no matching option elements are found
237
244
* @throws UnsupportedOperationException If the SELECT does not support multiple selections
238
245
*/
246
+ @ Override
239
247
public void deselectByValue (String value ) {
240
248
if (!isMultiple ()) {
241
249
throw new UnsupportedOperationException (
@@ -262,6 +270,7 @@ public void deselectByValue(String value) {
262
270
* @throws NoSuchElementException If no matching option elements are found
263
271
* @throws UnsupportedOperationException If the SELECT does not support multiple selections
264
272
*/
273
+ @ Override
265
274
public void deselectByIndex (int index ) {
266
275
if (!isMultiple ()) {
267
276
throw new UnsupportedOperationException (
@@ -289,6 +298,7 @@ public void deselectByIndex(int index) {
289
298
* @throws NoSuchElementException If no matching option elements are found
290
299
* @throws UnsupportedOperationException If the SELECT does not support multiple selections
291
300
*/
301
+ @ Override
292
302
public void deselectByVisibleText (String text ) {
293
303
if (!isMultiple ()) {
294
304
throw new UnsupportedOperationException (
0 commit comments