@@ -68,15 +68,15 @@ public boolean isMultiple() {
6868
6969 /**
7070 * @return This is done by checking the value of attributes in "visibility", "display", "opacity"
71- * Return false if visibility is set to 'hidden', display is 'none', or opacity is 0 or 0.0.
71+ * Return false if visibility is set to 'hidden', display is 'none', or opacity is 0 or 0.0.
7272 */
7373 private boolean hasCssPropertyAndVisible (WebElement webElement ) {
74- List <String > cssValueCandidates = Arrays .asList (new String []{"hidden" , "none" , "0" , "0.0" });
75- String [] cssPropertyCandidates = new String []{"visibility" , "display" , "opacity" };
74+ List <String > cssValueCandidates = Arrays .asList (new String [] {"hidden" , "none" , "0" , "0.0" });
75+ String [] cssPropertyCandidates = new String [] {"visibility" , "display" , "opacity" };
7676
7777 for (String property : cssPropertyCandidates ) {
78- String cssValue = webElement .getCssValue (property );
79- if (cssValueCandidates .contains (cssValue )) return false ;
78+ String cssValue = webElement .getCssValue (property );
79+ if (cssValueCandidates .contains (cssValue )) return false ;
8080 }
8181
8282 return true ;
@@ -169,19 +169,21 @@ public void selectByVisibleText(String text) {
169169 }
170170
171171 /**
172- * Selects all options that display text matching or containing the provided argument.
173- * This method first attempts to find an exact match and, if not found, will then attempt
174- * to find options that contain the specified text as a substring.
172+ * Selects all options that display text matching or containing the provided argument. This method
173+ * first attempts to find an exact match and, if not found, will then attempt to find options that
174+ * contain the specified text as a substring.
175175 *
176- * For example, when given "Bar", this would select an option like:
176+ * <p> For example, when given "Bar", this would select an option like:
177177 *
178178 * <p><option value="foo">Bar</option>
179179 *
180- * And also select an option like:
180+ * <p> And also select an option like:
181181 *
182- * <p><option value="baz">FooBar</option> or <option value="baz">1년납</option> when "1년" is provided.
182+ * <p><option value="baz">FooBar</option> or <option
183+ * value="baz">1년납</option> when "1년" is provided.
183184 *
184- * @param text The visible text to match against. It can be a full or partial match of the option text.
185+ * @param text The visible text to match against. It can be a full or partial match of the option
186+ * text.
185187 * @throws NoSuchElementException If no matching option elements are found
186188 */
187189 @ Override
@@ -191,11 +193,12 @@ public void selectByContainsVisibleText(String text) {
191193
192194 // try to find the option via XPATH ...
193195 List <WebElement > options =
194- element .findElements (
195- By .xpath (".//option[normalize-space(.) = " + Quotes .escape (text ) + "]" ));
196+ element .findElements (
197+ By .xpath (".//option[normalize-space(.) = " + Quotes .escape (text ) + "]" ));
196198
197199 for (WebElement option : options ) {
198- if (!hasCssPropertyAndVisible (option )) throw new NoSuchElementException ("Invisible option with text: " + text );
200+ if (!hasCssPropertyAndVisible (option ))
201+ throw new NoSuchElementException ("Invisible option with text: " + text );
199202 setSelected (option , true );
200203 if (!isMultiple ()) {
201204 return ;
@@ -210,14 +213,16 @@ public void selectByContainsVisibleText(String text) {
210213 if (searchText .isEmpty ()) {
211214 candidates = element .findElements (By .tagName ("option" ));
212215 } else {
213- candidates = element .findElements (
214- By .xpath (".//option[contains(., " + Quotes .escape (searchText ) + ")]" ));
216+ candidates =
217+ element .findElements (
218+ By .xpath (".//option[contains(., " + Quotes .escape (searchText ) + ")]" ));
215219 }
216220
217221 String trimmed = text .trim ();
218222 for (WebElement option : candidates ) {
219223 if (option .getText ().contains (trimmed )) {
220- if (!hasCssPropertyAndVisible (option )) throw new NoSuchElementException ("Invisible option with text: " + text );
224+ if (!hasCssPropertyAndVisible (option ))
225+ throw new NoSuchElementException ("Invisible option with text: " + text );
221226 setSelected (option , true );
222227 if (!isMultiple ()) {
223228 return ;
@@ -368,15 +373,15 @@ public void deSelectByContainsVisibleText(String text) {
368373
369374 String trimmed = text .trim ();
370375 List <WebElement > options =
371- element .findElements (
372- By .xpath (".//option[contains(., " + Quotes .escape (trimmed ) + ")]" ));
376+ element .findElements (By .xpath (".//option[contains(., " + Quotes .escape (trimmed ) + ")]" ));
373377
374378 if (options .isEmpty ()) {
375379 throw new NoSuchElementException ("Cannot locate option with text: " + text );
376380 }
377381
378382 for (WebElement option : options ) {
379- if (!hasCssPropertyAndVisible (option )) throw new NoSuchElementException ("Invisible option with text: " + text );
383+ if (!hasCssPropertyAndVisible (option ))
384+ throw new NoSuchElementException ("Invisible option with text: " + text );
380385 setSelected (option , false );
381386 }
382387 }
0 commit comments