Skip to content

Commit c1da1dd

Browse files
committed
Run format
Signed-off-by: Viet Nguyen Duc <[email protected]>
1 parent 0866faf commit c1da1dd

File tree

4 files changed

+38
-32
lines changed

4 files changed

+38
-32
lines changed

java/src/org/openqa/selenium/support/ui/ISelect.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,13 @@ public interface ISelect {
6161
void selectByVisibleText(String text);
6262

6363
/**
64-
* Select all options that display text matching or containing the argument. That is, when given "Bar"
65-
* this would select an option like:
64+
* Select all options that display text matching or containing the argument. That is, when given
65+
* "Bar" this would select an option like:
6666
*
6767
* <p>&lt;option value="foo"&gt;Bar&lt;/option&gt;
6868
*
69-
* Additionally, if no exact match is found, this will attempt to select options that contain the
70-
* argument as a substring. For example, when given "1년", this would select an option like:
69+
* <p>Additionally, if no exact match is found, this will attempt to select options that contain
70+
* the argument as a substring. For example, when given "1년", this would select an option like:
7171
*
7272
* <p>&lt;option value="bar"&gt;1년납&lt;/option&gt;
7373
*

java/src/org/openqa/selenium/support/ui/Select.java

Lines changed: 26 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -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>&lt;option value="foo"&gt;Bar&lt;/option&gt;
179179
*
180-
* And also select an option like:
180+
* <p>And also select an option like:
181181
*
182-
* <p>&lt;option value="baz"&gt;FooBar&lt;/option&gt; or &lt;option value="baz"&gt;1년납&lt;/option&gt; when "1년" is provided.
182+
* <p>&lt;option value="baz"&gt;FooBar&lt;/option&gt; or &lt;option
183+
* value="baz"&gt;1년납&lt;/option&gt; 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
}

java/test/org/openqa/selenium/support/ui/SelectElementTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ void shouldAllowOptionsToBeSelectedByContainsVisibleText() {
149149

150150
select.deselectAll();
151151
assertThatExceptionOfType(NoSuchElementException.class)
152-
.isThrownBy(() -> select.selectByContainsVisibleText("select_12"));
152+
.isThrownBy(() -> select.selectByContainsVisibleText("select_12"));
153153
}
154154

155155
@Test

java/test/org/openqa/selenium/support/ui/SelectTest.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
import static org.mockito.Mockito.verify;
2727
import static org.mockito.Mockito.when;
2828

29-
import java.util.ArrayList;
3029
import java.util.Arrays;
3130
import java.util.Collections;
3231
import java.util.List;
@@ -162,8 +161,9 @@ void shouldAllowOptionsToBeSelectedByContainsVisibleText() {
162161
final WebElement firstOption = mockOption("first", false);
163162

164163
final WebElement element = mockSelectWebElement("multiple");
165-
when(element.findElements(By.xpath(".//option[contains(., " + Quotes.escape(parameterText) + ")]")))
166-
.thenReturn(Collections.singletonList(firstOption));
164+
when(element.findElements(
165+
By.xpath(".//option[contains(., " + Quotes.escape(parameterText) + ")]")))
166+
.thenReturn(Collections.singletonList(firstOption));
167167
when(firstOption.getText()).thenReturn("foo bar");
168168
when(firstOption.isEnabled()).thenReturn(true);
169169

@@ -257,8 +257,9 @@ void shouldAllowOptionsToDeSelectedByContainsVisibleText() {
257257
final WebElement secondOption = mockOption("second", false);
258258

259259
final WebElement element = mockSelectWebElement("multiple");
260-
when(element.findElements(By.xpath(".//option[contains(., " + Quotes.escape(parameterText) + ")]")))
261-
.thenReturn(Arrays.asList(firstOption, secondOption));
260+
when(element.findElements(
261+
By.xpath(".//option[contains(., " + Quotes.escape(parameterText) + ")]")))
262+
.thenReturn(Arrays.asList(firstOption, secondOption));
262263

263264
Select select = new Select(element);
264265
select.deSelectByContainsVisibleText(parameterText);
@@ -340,6 +341,6 @@ void shouldThrowAnExceptionIfThereAreNoElementsToSelect() {
340341
.isThrownBy(() -> select.selectByVisibleText("also not there"));
341342

342343
assertThatExceptionOfType(NoSuchElementException.class)
343-
.isThrownBy(() -> select.selectByContainsVisibleText("also not there"));
344+
.isThrownBy(() -> select.selectByContainsVisibleText("also not there"));
344345
}
345346
}

0 commit comments

Comments
 (0)